/* =============================================================
   contact-page.css — Specific styles for contact.newandu.et
   Provides tab bar styling, modal overlays, radar scanner,
   user cards, caller ID, contact importer, and notifications.
   ============================================================= */

/* ---------- DISCOVERY TABS ---------- */
.discovery-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: fit-content;
    margin: 0 auto 1.5rem;
    max-width: 100%;
    overflow-x: auto;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-surface-2);
}

.tab-btn.active {
    color: #fff !important;
    background: var(--accent) !important;
    box-shadow: 0 4px 14px var(--accent-shadow);
}

.tab-content {
    animation: fadeInUp 0.35s ease both;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tab-content[hidden] {
    display: none !important;
}

/* ---------- EXPORT DROPDOWN MENU ---------- */
.dropdown-wrap {
    position: relative;
    display: inline-block;
}

.export-dropdown-menu {
    display: none !important;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 1000;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    min-width: 150px;
    padding: 0.35rem;
}

.export-dropdown-menu.show {
    display: block !important;
    animation: fadeInDown 0.18s ease both;
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.export-dropdown-item:hover {
    background: var(--bg-surface-2);
    color: var(--accent);
}

/* ---------- MODAL SYSTEM (CRITICAL) ---------- */
.modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10000 !important;
    padding: 1.25rem !important;
    overflow-y: auto;
}

.modal-backdrop[aria-hidden="false"] {
    display: flex !important;
}

.modal-backdrop[aria-hidden="true"],
.modal-backdrop:not([aria-hidden="false"]) {
    display: none !important;
}

.modal-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 540px;
    width: 100%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    position: relative;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-panel--featured {
    max-width: 460px;
    text-align: center;
}

.modal-panel--narrow {
    max-width: 440px;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-2);
}

.modal-close--abs {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.feature-icon-hero {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.feature-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.feature-desc {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.flex-col-stack-3 {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.link-muted-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color var(--transition);
}

.link-muted-btn:hover {
    color: var(--text-primary);
}

/* ---------- CONTACTS LOADER CARD ---------- */
.contacts-loader-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}

.contacts-loader-icon {
    font-size: 1.75rem;
    margin-right: 0.5rem;
}

.contacts-loader-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    display: inline;
}

.contacts-loader-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0.75rem;
    line-height: 1.5;
}

.contacts-actions-col {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.rep-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.rep-badge-warn {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ---------- RADAR SCANNER & LOCATION ---------- */
.location-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    gap: 1rem;
    flex-wrap: wrap;
}

.location-info h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.location-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.radar-scanner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.radar-box {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: radarPing 2.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.radar-circle:nth-child(1) { animation-delay: 0s; }
.radar-circle:nth-child(2) { animation-delay: 0.8s; }
.radar-circle:nth-child(3) { animation-delay: 1.6s; }

.radar-center-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 16px var(--accent);
    z-index: 2;
}

.radar-status {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

@keyframes radarPing {
    0% {
        width: 14px;
        height: 14px;
        opacity: 0.9;
    }
    100% {
        width: 140px;
        height: 140px;
        opacity: 0;
    }
}

/* ---------- USER GRID & CARDS ---------- */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all var(--transition);
}

.user-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    border: 1px solid var(--accent-border);
}

.user-info-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user-info-handle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------- SEARCH FORM & INPUTS ---------- */
.search-mode-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.search-mode-btn {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    border-radius: 9999px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.search-mode-btn:hover:not(.active) {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.search-mode-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 2px 8px var(--accent-shadow);
}

.search-input-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
}

.field {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.field-flex {
    flex: 1;
    min-width: 0;
}

.field-accent-border {
    border-color: var(--accent);
}

.field-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88rem;
}

.btn-emerald {
    background: var(--emerald) !important;
    color: #fff !important;
}

.btn-emerald:hover {
    filter: brightness(1.1);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
}

.btn-md {
    padding: 0.75rem 1.4rem;
    font-size: 0.9rem;
}

.section-title-lg {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.section-sub-lg {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ---------- NOTIFICATIONS BELL & DROPDOWN ---------- */
.notif-bell-wrap {
    position: relative;
    background: transparent;
    border: 1px solid var(--border);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.notif-bell-wrap:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 9999px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-base);
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    z-index: 1000;
    overflow: hidden;
    animation: modalPop 0.2s ease both;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-surface-2);
}

.notif-list {
    max-height: 280px;
    overflow-y: auto;
}

.notif-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background 0.15s;
}

.notif-item:hover {
    background: var(--bg-card-hover);
}

/* ---------- RESPONSIVE OVERRIDES ---------- */
@media (max-width: 860px) {
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1rem;
    }

    .notif-dropdown {
        width: calc(100vw - 2rem) !important;
        max-width: 320px !important;
        right: -10px !important;
    }
}

@media (max-width: 640px) {
    .discovery-tabs {
        width: 100%;
        justify-content: flex-start;
        padding: 0.25rem;
        gap: 0.25rem;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .search-input-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .search-input-row .btn {
        width: 100%;
    }

    .user-grid {
        grid-template-columns: 1fr;
    }

    .modal-panel {
        padding: 1.25rem;
        max-width: calc(100vw - 1.5rem);
    }

    .caller-id-hero {
        padding: 1.5rem 1rem;
    }

    .caller-id-hero h2 {
        font-size: 1.25rem;
    }

    .phone-input-group {
        flex-direction: column;
    }

    .phone-input-group .btn {
        width: 100%;
    }
}

@media (max-width: 420px) {
    .user-card {
        padding: 1rem;
    }

    .user-meta h4 {
        font-size: 0.95rem;
    }

    .tab-btn {
        padding: 0.45rem 0.65rem;
        font-size: 0.75rem;
    }
}

/* ---------- LOAD ENTIRE PHONEBOOK MODAL STYLES ---------- */
.modal-panel--phonebook {
    max-width: 580px;
    width: 100%;
}

.phonebook-hero-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(6, 95, 70, 0.15));
    border: 2px dashed rgba(16, 185, 129, 0.4);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    margin: 1.25rem 0;
    transition: all 0.2s ease;
}

.phonebook-hero-box.drag-over {
    border-color: var(--emerald);
    background: rgba(16, 185, 129, 0.22);
    transform: scale(1.02);
}

.phonebook-hero-icon {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.phonebook-hero-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
}

.phonebook-hero-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
}

.phonebook-drop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.device-guides-container {
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.device-guide-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.device-guide-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.guide-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    text-align: left;
    transition: border-color 0.15s;
}

.guide-card:hover {
    border-color: var(--border-hover);
}

.guide-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.guide-card-header h5 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.guide-card-body {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

.modal-actions-secondary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* =============================================================
   CONTACT TABLE CONTROLS, ALPHABET JUMP BAR & PAGINATION
   ============================================================= */
.alphabet-jump-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    padding: 0.4rem 0.5rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.alphabet-btn {
    min-width: 25px;
    height: 25px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.alphabet-btn:hover {
    background: rgba(2, 132, 199, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

.alphabet-btn.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.contacts-control-bar select:focus,
.contacts-control-bar input:focus {
    border-color: var(--accent);
    outline: none;
}

/* Responsive Bulk Contact Selection Modal */
#bulk-contact-select-modal .modal-panel {
    max-width: 680px !important;
    height: 90vh !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}

#bulk-contact-select-modal .modal-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

#bulk-contact-select-modal .bulk-toolbar {
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border);
}

#bulk-contact-select-modal .bulk-filter-row {
    flex-shrink: 0;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

#bulk-contact-select-modal #bulk-contact-list-container {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    max-height: none !important;
    min-height: 140px !important;
    padding: 0.75rem 1.25rem !important;
}

#bulk-contact-select-modal .modal-footer {
    flex-shrink: 0 !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10 !important;
    width: 100% !important;
    background: var(--bg-surface-1) !important;
    border-top: 1px solid var(--border) !important;
    padding: 0.85rem 1.25rem !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

@media (max-width: 640px) {
    #bulk-contact-select-modal .modal-panel {
        max-width: 96vw !important;
        width: 96vw !important;
        height: 94vh !important;
        max-height: 94vh !important;
        margin: auto !important;
        border-radius: var(--radius-md) !important;
    }

    #bulk-contact-select-modal .bulk-toolbar {
        padding: 0.5rem 0.75rem !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    #bulk-contact-select-modal .bulk-toolbar .flex-row {
        width: 100% !important;
        justify-content: space-between !important;
    }

    #bulk-contact-select-modal .bulk-filter-row {
        padding: 0.5rem 0.75rem !important;
    }

    #bulk-contact-select-modal #bulk-contact-list-container {
        padding: 0.5rem 0.75rem !important;
    }

    #bulk-contact-select-modal .modal-footer {
        padding: 0.75rem !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.6rem !important;
        align-items: stretch !important;
    }

    #bulk-contact-select-modal .modal-footer .bulk-footer-summary {
        text-align: center !important;
        width: 100% !important;
        font-size: 0.8rem !important;
    }

    #bulk-contact-select-modal .modal-footer .bulk-footer-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    #bulk-contact-select-modal #btn-confirm-bulk-sync {
        flex: 2 !important;
        min-height: 46px !important;
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: normal !important;
        text-align: center !important;
        box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35) !important;
    }

    #bulk-contact-select-modal .modal-footer button[data-action="close-modal"] {
        flex: 1 !important;
        min-height: 46px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

