/**
 * Country Selector styles for Rahkar Login
 * Modern, Professional Design with Rahkarnet Brand Guidelines
 */

/* ============================================
   Country Container
   ============================================ */
.rs-country-container {
    position: relative;
    display: flex;
    align-items: stretch;
}

/* ============================================
   Country Selector Button
   ============================================ */
.rs-country-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.rs-country-selector-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: 1;
}

.rs-selected-flag {
    display: flex;
    align-items: center;
    padding: 0 10px;
    height: 46px;
    background: var(--rs-bg, #f9fafb);
    border: 1px solid var(--rs-border, #e5e7eb);
    border-left: none;
    border-radius: var(--rs-radius, 8px) 0 0 var(--rs-radius, 8px);
    transition: var(--rs-transition, all 0.2s ease);
    gap: 4px;
}

.rs-selected-flag:hover {
    background: var(--rs-border-light, #f3f4f6);
}

.rs-country-selector:focus-within .rs-selected-flag {
    border-color: var(--rs-primary, #2563EB);
    background: var(--rs-white, #ffffff);
}

/* ============================================
   Flag Image
   ============================================ */
.rs-flag-img {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Dial Code
   ============================================ */
.rs-dial-code {
    font-size: 14px;
    font-weight: 500;
    color: var(--rs-text, #1f2937);
    direction: ltr;
    font-family: system-ui, -apple-system, sans-serif;
}

/* ============================================
   Arrow Indicator
   ============================================ */
.rs-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--rs-text-light, #6b7280);
    transition: var(--rs-transition, all 0.2s ease);
    margin-left: 4px;
}

.rs-country-selector:hover .rs-arrow {
    border-top-color: var(--rs-text, #1f2937);
}

.rs-country-list.rs-show + .rs-arrow,
.rs-country-selector.rs-open .rs-arrow {
    transform: rotate(180deg);
}

/* ============================================
   Phone Input Field
   ============================================ */
.rs-country-container .rs-form-group {
    flex-grow: 1;
    margin: 0;
}

.rs-country-container input[type="tel"] {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    direction: ltr;
    text-align: left;
    height: 46px;
}

.rs-country-container input[type="tel"]:focus {
    position: relative;
    z-index: 1;
}

/* ============================================
   Country List Dropdown
   ============================================ */
.rs-country-list {
    position: absolute;
    z-index: 100;
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    width: 320px;
    top: calc(100% + 4px);
    left: 0;
    background: var(--rs-white, #ffffff);
    border: 1px solid var(--rs-border, #e5e7eb);
    box-shadow: var(--rs-shadow-lg, 0 20px 25px -5px rgb(0 0 0 / 0.1));
    border-radius: var(--rs-radius-lg, 12px);
    display: none;
    overflow: hidden;
}

.rs-country-list.rs-show {
    display: block;
    animation: rsDropdownFadeIn 0.2s ease;
}

@keyframes rsDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Country Search Input
   ============================================ */
.rs-country-search {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid var(--rs-border-light, #f3f4f6);
    font-size: 14px;
    color: var(--rs-text, #1f2937);
    background: var(--rs-bg, #f9fafb);
    box-sizing: border-box;
    outline: none;
    transition: var(--rs-transition, all 0.2s ease);
}

.rs-country-search::placeholder {
    color: var(--rs-text-lighter, #9ca3af);
}

.rs-country-search:focus {
    background: var(--rs-white, #ffffff);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ============================================
   Country List Items Container
   ============================================ */
.rs-country-list-items {
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Custom Scrollbar */
.rs-country-list-items::-webkit-scrollbar {
    width: 6px;
}

.rs-country-list-items::-webkit-scrollbar-track {
    background: var(--rs-bg, #f9fafb);
}

.rs-country-list-items::-webkit-scrollbar-thumb {
    background: var(--rs-border, #e5e7eb);
    border-radius: 3px;
}

.rs-country-list-items::-webkit-scrollbar-thumb:hover {
    background: var(--rs-text-lighter, #9ca3af);
}

/* ============================================
   Country Item
   ============================================ */
.rs-country-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--rs-transition, all 0.2s ease);
    gap: 12px;
    border-bottom: 1px solid var(--rs-border-light, #f3f4f6);
}

.rs-country-item:last-child {
    border-bottom: none;
}

.rs-country-item:hover {
    background: var(--rs-primary-light, #dbeafe);
}

.rs-country-item.rs-selected {
    background: var(--rs-primary-light, #dbeafe);
}

.rs-country-item.rs-selected .rs-country-name {
    color: var(--rs-primary, #2563EB);
    font-weight: 600;
}

.rs-country-item .rs-flag-img {
    width: 28px;
    height: 20px;
    flex-shrink: 0;
}

/* ============================================
   Country Name & Code
   ============================================ */
.rs-country-name {
    font-size: 14px;
    color: var(--rs-text, #1f2937);
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rs-country-code {
    font-size: 13px;
    font-weight: 500;
    color: var(--rs-text-light, #6b7280);
    direction: ltr;
    font-family: system-ui, -apple-system, monospace;
    flex-shrink: 0;
}

/* ============================================
   No Results Message
   ============================================ */
.rs-country-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--rs-text-light, #6b7280);
    font-size: 14px;
}

/* ============================================
   Hide Country Selector Mode
   ============================================ */
.rs-hide-country-selector .rs-country-selector {
    display: none;
}

.rs-hide-country-selector .rs-country-container input[type="tel"] {
    border-radius: var(--rs-radius, 8px) !important;
    border-right: 1.5px solid var(--rs-border, #e5e7eb) !important;
}

/* ============================================
   Disable International Mode
   ============================================ */
.rs-disable-international .rs-country-selector {
    pointer-events: none;
    opacity: 0.6;
}

.rs-disable-international .rs-selected-flag {
    cursor: not-allowed;
}

.rs-disable-international .rs-arrow {
    display: none;
}

/* ============================================
   RTL Support
   ============================================ */
.rtl .rs-country-container,
html[dir="rtl"] .rs-country-container,
body.rtl .rs-country-container {
    flex-direction: row-reverse;
}

.rtl .rs-selected-flag,
html[dir="rtl"] .rs-selected-flag,
body.rtl .rs-selected-flag {
    border-radius: var(--rs-radius, 8px) 0 0 var(--rs-radius, 8px);
    border-right: 1px solid var(--rs-border, #e5e7eb);
    border-left: none;
    flex-direction: row-reverse;
}

.rtl .rs-flag-img,
html[dir="rtl"] .rs-flag-img,
body.rtl .rs-flag-img {
    margin-right: 0;
}

.rtl .rs-arrow,
html[dir="rtl"] .rs-arrow,
body.rtl .rs-arrow {
    margin-left: 0;
    margin-right: 4px;
}

.rtl .rs-country-container input[type="tel"],
html[dir="rtl"] .rs-country-container input[type="tel"],
body.rtl .rs-country-container input[type="tel"] {
    border-radius: 0 var(--rs-radius, 8px) var(--rs-radius, 8px) 0 !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.rtl .rs-country-list,
html[dir="rtl"] .rs-country-list {
    left: auto;
    right: 0;
}

.rtl .rs-country-item,
html[dir="rtl"] .rs-country-item {
    flex-direction: row-reverse;
}

.rtl .rs-country-name,
html[dir="rtl"] .rs-country-name {
    text-align: right;
}

.rtl .rs-country-search,
html[dir="rtl"] .rs-country-search {
    text-align: right;
}

.rtl .rs-hide-country-selector .rs-country-container input[type="tel"],
html[dir="rtl"] .rs-hide-country-selector .rs-country-container input[type="tel"],
body.rtl .rs-hide-country-selector .rs-country-container input[type="tel"] {
    border-radius: var(--rs-radius, 8px) !important;
    border: 1px solid var(--rs-border, #e5e7eb) !important;
}

/* ============================================
   Mobile Responsiveness
   ============================================ */
@media (max-width: 480px) {
    .rs-country-list {
        width: calc(100vw - 48px);
        max-width: 320px;
    }

    .rs-selected-flag {
        padding: 0 10px;
    }

    .rs-dial-code {
        font-size: 13px;
    }

    .rs-country-item {
        padding: 10px 14px;
    }

    .rs-country-name {
        font-size: 13px;
    }

    .rs-country-code {
        font-size: 12px;
    }
}

/* ============================================
   Focus States for Accessibility
   ============================================ */
.rs-country-item:focus {
    outline: none;
    background: var(--rs-primary-light, #dbeafe);
}

.rs-country-search:focus-visible {
    outline: 2px solid var(--rs-primary, #2563EB);
    outline-offset: -2px;
}

/* Keyboard navigation highlight */
.rs-country-item.rs-highlighted {
    background: var(--rs-primary-light, #dbeafe);
}

/* ============================================
   Loading State
   ============================================ */
.rs-country-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.rs-country-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--rs-border, #e5e7eb);
    border-top-color: var(--rs-primary, #2563EB);
    border-radius: 50%;
    animation: rsSpin 0.8s linear infinite;
}

@keyframes rsSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
