/* ============================================
   CSS VARIABLES - ALL CUSTOMIZATION IN ONE PLACE
   ============================================ */
:root {
    /* ========== COLOR SYSTEM (Purple/Blue Theme) ========== */
    /* Primary Colors */
    --color-primary: #8e61ff;           /* Main purple - buttons, accents, highlights */
    --color-secondary:#527dff ; 
    --color-accent:#70b5ff ;        /* Blue - hover states, focus */

    /* Background Colors */
    --color-bg-dark: #242027;           /* Darkest - main background */
    --color-bg-medium: #2c2a3d;         /* Medium - cards, panels */
    --color-bg-light: #2c2a3d;          /* Lightest - top bar, borders */
    
    /* Text Colors */
    --color-text-primary: #dae4ff;      /* Main text (white) */
    --color-text-secondary: #b8b8b8;    /* Secondary/muted text */
    --color-text-disabled: #8a8a8a;     /* Disabled/placeholder text */
    
    /* Semantic Colors */
    --color-error: #ff4444;             /* Error red */
    --color-success: #00c851;           /* Success green */
    
    /* Opacity Variants (for hover/focus states) */
    --color-primary-alpha-50: rgba(142, 97, 255, 0.5);
    --color-primary-alpha-10: rgba(142, 97, 255, 0.1);
    --color-error-alpha-10: rgba(255, 68, 68, 0.1);
    --color-success-alpha-10: rgba(0, 200, 81, 0.1);
    
    /* ========== TOP BAR ========== */
    --topbar-bg-color: var(--color-bg-light);
    --topbar-height: 70px;
    --topbar-padding: 0 20px;
    
    /* Primary text (AFC) styling */
    --topbar-primary-font-family: 'Orbitron', sans-serif;
    --topbar-primary-font-size: 50px;
    --topbar-primary-font-weight: 800;
    --topbar-primary-font-style: normal;
    --topbar-primary-color: var(--color-primary);
    --topbar-primary-vertical-offset: -1px;
    
    /* Secondary text (CONTACT MANAGER) styling */
    --topbar-secondary-font-family: 'Montserrat', sans-serif;
    --topbar-secondary-font-size: 36px;
    --topbar-secondary-font-weight: 600;
    --topbar-secondary-font-style: normal;
    --topbar-secondary-color: var(--color-text-primary);
    --topbar-secondary-vertical-offset: 0px;
    
    /* Spacing between the two texts */
    --topbar-text-gap: 15px;
    
    /* ========== SCROLLBAR ========== */
    --scrollbar-width: 8px;
    --scrollbar-track-bg: transparent;
    --scrollbar-thumb-bg: var(--color-primary-alpha-50);
    --scrollbar-thumb-hover-bg: var(--color-primary);
    
    /* ========== AUTH PAGE ========== */
    /* Auth Container */
    --auth-bg-color: var(--color-bg-dark);
    --auth-card-bg: var(--color-bg-medium);
    --auth-card-max-width: 450px;
    --auth-card-padding: 40px;
    --auth-card-border-radius: 12px;
    --auth-card-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); 
    
    /* Auth Title */
    --auth-title-color: var(--color-text-primary);
    --auth-title-font-size: 48px;
    --auth-title-font-family: 'Orbitron', sans-serif;
    --auth-title-font-weight: 900;
    
    /* Tabs */
    --tab-inactive-color: var(--color-text-disabled);
    --tab-active-color: var(--color-primary);
    --tab-border-color: var(--color-primary);
    --tab-font-size: 16px;
    --tab-font-weight: 600;
    --tab-spacing: 40px;
    
    /* Form Inputs */
    --input-bg-color: var(--color-bg-dark);
    --input-border-color: var(--color-primary);
    --input-text-color: var(--color-text-primary);
    --input-placeholder-color: var(--color-text-disabled);
    --input-focus-border-color: var(--color-secondary);
    --input-padding: 14px 16px;
    --input-border-radius: 8px;
    --input-font-size: 16px;
    
    /* Form Labels */
    --label-color: var(--color-text-secondary);
    --label-font-size: 14px;
    --label-font-weight: 500;
    
    /* Buttons */
    --btn-primary-bg: var(--color-primary);
    --btn-primary-hover-bg: var(--color-secondary);
    --btn-primary-text: var(--color-text-primary);
    --btn-padding: 16px;
    --btn-border-radius: 8px;
    --btn-font-size: 16px;
    --btn-font-weight: 700;
    
    /* Messages */
    --error-color: var(--color-error);
    --error-bg: var(--color-error-alpha-10);
    --success-color: var(--color-success);
    --success-bg: var(--color-success-alpha-10);
    
    /* Spacing */
    --form-group-spacing: 20px;
}




/* ============================================
   GLOBAL RESETS
   ============================================ */
/* Apply Border-Box to EVERYTHING */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-bg) var(--scrollbar-track-bg);
}

body 
{
    background-color: var(--color-bg-dark);
    margin: 0;
    padding: 0;
}

/* Custom Scrollbar for Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-bg);
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover-bg);
}

/* Top Bar Styling */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--topbar-height);
    background-color: var(--topbar-bg-color);
    color: var(--topbar-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--topbar-padding);
    box-sizing: border-box;
    z-index: 1000;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.top-bar__content {
    display: flex;
    align-items: center;
    gap: var(--topbar-text-gap);
}

.top-bar__text--primary {
    font-family: var(--topbar-primary-font-family);
    font-size: var(--topbar-primary-font-size);
    font-weight: var(--topbar-primary-font-weight);
    font-style: var(--topbar-primary-font-style);
    color: var(--topbar-primary-color);
    line-height: 1;
    transform: translateY(var(--topbar-primary-vertical-offset));
}

/* Logo styling - replaces AFC text */
.top-bar__logo {
    height: 100px;
    width: auto;
    display: block;
    object-fit: contain;
    transform: translateY(var(--topbar-primary-vertical-offset));
}

.top-bar__text--secondary {
    font-family: var(--topbar-secondary-font-family);
    font-size: var(--topbar-secondary-font-size);
    font-weight: var(--topbar-secondary-font-weight);
    font-style: var(--topbar-secondary-font-style);
    color: var(--topbar-secondary-color);
    line-height: 1;
    transform: translateY(var(--topbar-secondary-vertical-offset));
}

/* Add padding to body content to account for fixed top bar */
body > *:not(.top-bar) {
    margin-top: var(--topbar-height);
}

/* Help/About Button in Top Bar */
.top-bar__help-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.top-bar__help-btn:hover {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(142, 97, 255, 0.4);
}

.top-bar__help-btn:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* Logout Button in Top Bar (contacts page only) */
.top-bar__logout-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-bar__logout-btn:hover {
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(142, 97, 255, 0.4);
}

.top-bar__logout-btn:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.logout-icon {
    user-select: none;
    pointer-events: none;
    font-size: 24px;
    line-height: 1;
}

/* ============================================
   AUTH CONTAINER & CARD
   ============================================ */
.auth-container {
    min-height: calc(100vh - var(--topbar-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background-color: var(--auth-bg-color);
}

.auth-card {
    width: 100%;
    max-width: var(--auth-card-max-width);
    background-color: var(--auth-card-bg);
    border-radius: var(--auth-card-border-radius);
    box-shadow: var(--auth-card-shadow);
    padding: var(--auth-card-padding);
}

.auth-card__header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card__title {
    font-family: var(--auth-title-font-family);
    font-size: var(--auth-title-font-size);
    font-weight: var(--auth-title-font-weight);
    color: var(--auth-title-color);
    margin: 0;
    letter-spacing: 2px;
}






/* ============================================
   TABS
   ============================================ */
.auth-tabs {
    display: flex;
    gap: var(--tab-spacing);
    margin-bottom: 32px;
    border-bottom: 2px solid var(--color-bg-light);
}

.auth-tabs__tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--tab-inactive-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--tab-font-size);
    font-weight: var(--tab-font-weight);
    padding: 12px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    letter-spacing: 1px;
}

.auth-tabs__tab::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--tab-border-color);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.auth-tabs__tab--active {
    color: var(--tab-active-color);
}

.auth-tabs__tab--active::after {
    transform: scaleX(1);
}

.auth-tabs__tab:hover {
    color: var(--tab-active-color);
}






/* ============================================
   FORMS
   ============================================ */
.auth-form {
    display: block;
}

.auth-form--hidden {
    display: none;
}

.form-group {
    margin-bottom: var(--form-group-spacing);
}

.form-label {
    display: block;
    color: var(--label-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--label-font-size);
    font-weight: var(--label-font-weight);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: var(--input-padding);
    background-color: var(--input-bg-color);
    border: 2px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    color: var(--input-text-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--input-font-size);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.form-input::placeholder {
    color: var(--input-placeholder-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--input-focus-border-color);
    box-shadow: 0 0 0 3px var(--color-primary-alpha-10);
}

/* Error state for form inputs */
.form-input--error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px var(--color-error-alpha-10) !important;
}

.form-input--error:focus {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px var(--color-error-alpha-10) !important;
}

/* Password Input Wrapper */
.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-input-wrapper .form-input {
    padding-right: 45px; /* Make room for the eye icon */
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
    font-size: 20px;
    line-height: 1;
}

.password-toggle-btn:hover {
    color: var(--color-primary);
}

.password-toggle-btn:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
    border-radius: 4px;
}

.eye-icon {
    user-select: none;
    pointer-events: none;
}

/* Override browser autofill styling */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus,
.form-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--input-bg-color) inset !important;
    -webkit-text-fill-color: var(--input-text-color) !important;
    box-shadow: 0 0 0 1000px var(--input-bg-color) inset !important;
    border-color: var(--input-border-color) !important;
    transition: background-color 5000s ease-in-out 0s;
}



/* ===============================
   ACCESS UI DIV - MAIN CONTENT CONTAINER
   =============================== */
#accessUIDiv {
    padding-top: 20px;         /* minimal gap below the fixed top bar */
}

/* ===============================
   CONTACT SEARCH RESULT MESSAGE
   =============================== */
#contactSearchResult {
    display: block;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin: 10px 0;
}

/* ===============================
   TOP CONTROLS CONTAINER - CENTERED
   =============================== */
.top-controls {
    display: flex;
    flex-direction: row;         /* arrange horizontally */
    align-items: center;         /* center vertically */
    justify-content: center;     /* center horizontally */
    gap: 16px;                   /* spacing between search and add button */
    margin: 0 0 0.5rem 0;        /* minimal bottom margin */
}

/* ===============================
   SEARCH BAR - PILL SHAPE, RESPONSIVE
   =============================== */
.search-container {
    display: flex;
    width: clamp(300px, 40%, 450px);  /* slightly narrower to fit button beside it */
    height: 48px;
    border-radius: 999px;             /* pill shape */
    overflow: hidden;
    background-color: var(--input-bg-color);
    box-shadow: 0 0 0 1px rgba(155, 108, 255, 0.3);
    transition: box-shadow 0.2s ease, width 0.2s ease;
}

/* Focus highlight */
.search-container:focus-within {
    box-shadow: 0 0 0 2px var(--color-primary-alpha-50);
}

/* INPUT - 3/4 of total pill, never smaller than 200px */
.search-container input[type="text"] {
    flex: 3 1 auto;                 /* grow 3 parts, shrink if needed */
    min-width: 200px;                /* ensures input never too small */
    padding: 12px 20px;
    border: none;
    outline: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    background-color: transparent;
    color: var(--input-text-color);
}

/* BUTTON - 1/4 of total pill, never smaller than 48px */
.search-container button {
    flex: 1 0 auto;                  /* 1 part of 4, do not shrink */
    min-width: 48px;                 /* ensures button always visible */
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.search-container button:hover {
    background-color: var(--color-secondary);
    transform: translateY(-1px);
}

.search-container button:active {
    transform: translateY(0);
}

/* Accessibility: focus outlines */
.search-container input:focus-visible,
.search-container button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===============================
   ADD CONTACT BUTTON - RIGHT OF SEARCH
   =============================== */
.add-button {
    width: auto;                      /* auto width for content */
    min-width: 150px;                 /* minimum width */
    padding: 0 24px;                  /* horizontal padding */
    height: 48px;                     /* match search bar height */
    background-color: var(--color-primary);
    color: var(--color-text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;              /* prevent text wrapping */
}

.add-button:hover {
    background-color: var(--color-secondary);
    transform: translateY(-1px);
}

.add-button:active {
    transform: translateY(0);
}

.add-button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===============================
   RESPONSIVE LAYOUT
   =============================== */
@media (max-width: 768px) {
    /* Stack vertically on smaller screens */
    .top-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-container {
        width: clamp(300px, 80%, 500px);
        height: 52px; /* Slightly taller for better touch targets */
    }
    
    .add-button {
        width: clamp(150px, 30%, 200px);
        height: 52px; /* Match search bar height */
    }
}

@media (max-width: 600px) {
    /* Override legacy #searchText ID selector for mobile */
    #searchText {
        font-size: 24px !important; /* Need !important to override ID selector specificity */
        padding: 10px 8px !important;
    }
    
    /* Make search input text smaller so placeholder fits without being cut off */
    .search-container input[type="text"] {
        padding: 10px 8px;
        font-size: 24px;
        min-width: 120px; /* Reduce min-width on mobile */
    }
    
    .search-container button {
        font-size: 14px;
    }
    
    .add-button {
        font-size: 14px;
    }
    
    /* Hide Phone Number and Email columns on mobile - show only First Name and Last Name */
    .table thead th:nth-child(3),
    .table thead th:nth-child(4),
    .table tbody td:nth-child(3),
    .table tbody td:nth-child(4) {
        display: none;
    }
}








/* ============================================
   TABLE CONTAINER (for scrolling + sticky header)
   ============================================ */

.table-container {
    margin-top: 45px;                  /* Override global body > * rule - reduced from 70px */
    margin-left: 20px;
    margin-right: 20px;
    margin-bottom: 20px;
    max-height: 70vh;                  /* Maximum 70% of viewport height - responsive to all screens */
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 12px;
    background-color: var(--color-bg-medium);
}

/* ============================================
   TABLE
   ============================================ */

.table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    background-color: var(--color-bg-medium);
    font-family: 'Montserrat', sans-serif;
}

/* ============================================
   STICKY HEADER
   ============================================ */

.table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table thead th {
    background-color: var(--color-bg-light);
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary-alpha-50);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Sortable column headers (first two columns only) */
.table thead th:nth-child(1),
.table thead th:nth-child(2) {
    cursor: pointer;
    user-select: none;
}

.table thead th:nth-child(1):hover,
.table thead th:nth-child(2):hover {
    background-color: rgba(142, 97, 255, 0.1);
}

/* Sort indicators */
.table thead th.sorted-asc::after,
.table thead th.sorted-desc::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

.table thead th.sorted-asc::after {
    border-bottom: 6px solid var(--color-primary);
}

.table thead th.sorted-desc::after {
    border-top: 6px solid var(--color-primary);
}

/* Round the top corners of the header */
.table thead th:first-child {
    border-top-left-radius: 12px;
}

.table thead th:last-child {
    border-top-right-radius: 12px;
}

/* ============================================
   BODY CELLS
   ============================================ */

.table td {
    padding: 14px 16px;
    color: var(--color-text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s ease;
}

/* ============================================
   SUBTLE COLUMN SEPARATORS
   ============================================ */

.table th:not(:last-child),
.table td:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

/* ============================================
   ZEBRA STRIPING
   ============================================ */

.table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ============================================
`      ROW HOVER & CLICKABLE ROWS
   ============================================ */

.table tbody tr {
    cursor: pointer;
}

.table tbody tr:hover {
    background-color: var(--color-primary-alpha-10);
}

/* Remove last row border */
.table tbody tr:last-child td {
    border-bottom: none;
}






/* ============================================
   BUTTONS
   ============================================ */
.btn {
    width: 100%;
    padding: var(--btn-padding);
    border: none;
    border-radius: var(--btn-border-radius);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--btn-font-size);
    font-weight: var(--btn-font-weight);
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.btn--primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.btn--primary:hover {
    background-color: var(--btn-primary-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(112, 181, 255, 0.3);
}

.btn--primary:active {
    transform: translateY(0);
}

.btn--secondary {
    background-color: var(--color-bg-medium);
    color: var(--color-text-primary);
    border: 2px solid var(--color-primary);
}

.btn--secondary:hover {
    background-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142, 97, 255, 0.3);
}

.btn--secondary:active {
    transform: translateY(0);
}

.btn--secondary:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* ============================================
   MESSAGES
   ============================================ */
.form-message {
    padding: 12px 16px;
    border-radius: var(--input-border-radius);
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    margin-bottom: 20px;
    display: none;
    animation: slideIn 0.3s ease;
}

.form-message--error {
    background-color: var(--error-bg);
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
}

.form-message--success {
    background-color: var(--success-bg);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.form-message:not(:empty) {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ============================================
   MODAL OVERLAY
   ============================================ */

#addContactModal,
#viewContactModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: none; /* controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
    overflow-y: auto; /* Allow scrolling if modal is taller than viewport */
    padding: 20px 0; /* Add vertical padding for breathing room */
}

#deleteConfirmModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: none; /* controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 2100; /* Higher than other modals */
    animation: fadeIn 0.2s ease;
    overflow-y: auto; /* Allow scrolling if modal is taller than viewport */
    padding: 20px 0; /* Add vertical padding for breathing room */
}

/* When JS sets display:block, this makes it flex */
#addContactModal[style*="block"],
#viewContactModal[style*="block"],
#deleteConfirmModal[style*="block"] {
    display: flex !important;
}

/* ============================================
   MODAL CARD
   ============================================ */

.modal-content {
    background: var(--color-bg-medium);
    padding: 32px;
    width: 100%;
    max-width: 550px;
    max-height: 90vh; /* Prevent modal from being taller than viewport */
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto; /* Allow scrolling within modal if content is too tall */
    margin: auto; /* Center in scrollable container */
}

/* Smaller modal for confirmations */
.modal-content--small {
    max-width: 400px;
    text-align: center;
}

/* ============================================
   MODAL HEADER (for title + delete button)
   ============================================ */

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    position: relative;
    gap: 16px;
}

/* ============================================
   MODAL TITLE
   ============================================ */

.modal-content h2 {
    margin: 0;
    font-family: var(--auth-title-font-family);
    font-size: 28px;
    color: var(--color-text-primary);
    flex: 1;
    text-align: left;
    line-height: 1.2;
}

/* For Add Contact modal (no header wrapper) */
.modal-content > h2 {
    margin: 0 0 24px 0;
    text-align: center;
}

/* ============================================
   MODAL HEADER BUTTONS (edit and delete)
   ============================================ */

.modal-header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.modal-action-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50%;
    background-color: transparent !important;
    border: 2px solid var(--color-primary) !important;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.modal-action-btn:hover {
    background-color: var(--color-primary) !important;
    color: var(--color-text-primary);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(142, 97, 255, 0.4);
}

/* Delete button specific hover (red) */
.modal-action-btn:hover .delete-icon {
    color: white;
}

#deleteContactBtn:hover {
    background-color: var(--color-error) !important;
    border-color: var(--color-error) !important;
}

#deleteContactBtn:hover {
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
}

.modal-action-btn:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.delete-icon,
.edit-icon {
    user-select: none;
    pointer-events: none;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

/* ============================================
   VIEW MODE INFO GROUPS
   ============================================ */

.info-group {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.info-label {
    flex-shrink: 0;
    width: 130px;
    text-align: right;
    color: var(--label-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--label-font-size);
    font-weight: var(--label-font-weight);
    letter-spacing: 0.5px;
}

.info-value {
    flex: 1;
    color: var(--color-text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    padding: 14px 16px;
    background-color: var(--color-bg-dark);
    border-radius: 8px;
    min-height: 48px;
    display: flex;
    align-items: center;
    word-break: break-word; /* Break long words/emails to prevent overflow */
    overflow-wrap: break-word; /* Additional overflow protection */
}

.info-value:empty::before {
    content: '—';
    color: var(--color-text-disabled);
}

/* ============================================
   MODAL FORM GROUPS (Edit Mode)
   ============================================ */

.modal-content .form-group {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.modal-content .form-label {
    flex-shrink: 0;
    width: 130px;
    text-align: right;
    color: var(--label-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--label-font-size);
    font-weight: var(--label-font-weight);
    letter-spacing: 0.5px;
}

/* ============================================
   MODAL INPUTS
   ============================================ */

.modal-content .form-input {
    width: 100%;
    padding: var(--input-padding);
    background-color: var(--input-bg-color);
    border: 2px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    color: var(--input-text-color);
    font-family: 'Montserrat', sans-serif;
    font-size: var(--input-font-size);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.modal-content .form-input::placeholder {
    color: var(--input-placeholder-color);
}

.modal-content .form-input:focus {
    outline: none;
    border-color: var(--input-focus-border-color);
    box-shadow: 0 0 0 3px var(--color-primary-alpha-10);
}

.modal-content input[type="hidden"] {
    display: none;
}

/* ============================================
   MODAL BUTTONS
   ============================================ */

.modal-content button {
    padding: 12px;
    margin-top: 8px;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

/* Close button in view mode - full width */
#closeViewBtn {
    width: 100%;
    background: var(--color-primary);
    color: var(--color-text-primary);
}

#closeViewBtn:hover {
    background: var(--color-secondary);
    transform: translateY(-2px);
}

/* Modal button group for side-by-side buttons */
.modal-button-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-button-group button {
    flex: 1;
    margin-top: 0;
}

/* Save button in edit mode */
.modal-button-group button:first-child {
    background: var(--color-primary);
    color: var(--color-text-primary);
}

.modal-button-group button:first-child:hover {
    background: var(--color-secondary);
    transform: translateY(-2px);
}

/* Cancel button in edit mode */
.modal-button-group button:last-child {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-secondary);
}

.modal-button-group button:last-child:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* ============================================
   CONFIRMATION MODAL STYLES
   ============================================ */

.confirm-message {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    color: var(--color-text-primary);
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-confirm-delete,
.btn-confirm-cancel {
    flex: 1;
    max-width: 150px;
    padding: 12px 24px;
    margin-top: 0;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-confirm-delete {
    background-color: var(--color-error) !important;
    color: white !important;
}

.btn-confirm-delete:hover {
    background-color: #cc0000 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
}

.btn-confirm-cancel {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: var(--color-text-secondary) !important;
}

.btn-confirm-cancel:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateY(-2px);
}

/* ============================================
   MODAL MESSAGES
   ============================================ */

#contactAddResult,
#contactEditResult,
#contactDeleteResult {
    font-size: 14px;
    text-align: center;
    margin-top: 8px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   MOBILE
   ============================================ */

@media (max-width: 600px) {
    .modal-content {
        width: 95%; /* Use more screen width on mobile */
        padding: 20px;
        max-height: 85vh; /* Leave more room for mobile navigation bars */
    }
    
    /* Stack form labels vertically on mobile for better readability */
    .modal-content .form-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .modal-content .form-label {
        width: auto;
        text-align: left;
    }
    
    /* Stack info groups vertically on mobile */
    .info-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .info-label {
        width: auto;
        text-align: left;
    }
    
    /* Increase button sizes for better touch targets (44px minimum) */
    .modal-content button {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Make modal action buttons (edit/delete) larger for touch */
    .modal-action-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px;
    }
}

/* ===============================
   LANDSCAPE MOBILE OPTIMIZATION
   =============================== */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    /* Handle phone in landscape mode - very limited vertical space */
    .modal-content {
        max-height: 80vh; /* Use most of available height */
        padding: 15px; /* Reduce padding to save space */
    }
    
    /* Make modals more compact in landscape */
    .modal-content .form-group,
    .info-group {
        margin-bottom: 12px; /* Reduce spacing */
    }
    
    .modal-content h2 {
        font-size: 22px; /* Smaller title */
        margin-bottom: 15px;
    }
}







/* ============================================
   LEGACY STYLES (Keep for other pages)
   ============================================ */
#searchText {
    font-size: 30px;
}

#colorText {
    font-size: 30px;
}

#userName {
    display: inline-block;
    width: 80%;
    margin-left: 10%;
    text-align: center;
}

#logoutButton {
    width: 20%;
    margin-left: 40%;
}

select {
    width: 30%;
    margin-left: 35%;
    margin-top: 2%;
    font-size: 0.75em;
    font-family: 'Ubuntu', sans-serif;
}

#colorSearchResult {
    display: none;
}

#colorAddResult {
    display: inline-block;
    font-size: 0.8em;
    width: 90%;
    text-align: center;
    margin-left: 5%;
    margin-top: 2%;
    margin-bottom: 1%;
    font-family: 'Ubuntu', sans-serif;
    color: var(--color-error);
}

/* ========== ABOUT PAGE ========== */
.about-back-btn {
    position: absolute;
    top: 30px;        /* Original desktop position - looks good */
    left: 30px;
    z-index: 50;
    padding: 10px 20px;
    font-size: 14px;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.back-arrow {
    font-size: 16px;
    line-height: 1;
    display: inline-block;
}

.about-card {
    max-width: 1000px;
    padding: 40px;
}

.about-section {
    margin-bottom: 40px;
    text-align: left;
}

.about-section__title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.about-section__text {
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    line-height: 1.8;
    color: var(--color-text-primary);
    margin: 0;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    color: var(--color-text-primary);
    text-align: center;
    font-family: 'Montserrat', sans-serif;
}

.team-member-card {
    padding: 25px;
    background: var(--color-bg-dark);
    border-radius: 8px;
    border: 1px solid var(--color-primary);
    transition: transform 0.2s, border-color 0.2s;
}

.team-member-card:hover {
    transform: translateY(-5px);
    border-color: var(--color-secondary);
}

.team-member-card:focus-within {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.team-member-card h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
}

.team-member-card p {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Mobile Optimization */
@media screen and (max-width: 600px) {
    /* 1. Make the card fit the screen width */
    .auth-card {
        width: 90%;       /* Sets width to 90% of screen */
        margin: 0 auto;   /* Centers it */
        padding: 20px;    /* Reduces internal spacing */
    }

    /* 2. Slightly shrink the big title so it doesn't wrap weirdly */
    .auth-card__title {
        font-size: 32px; 
    }
    
    /* 3. About page mobile adjustments */
    /* Push content down to make room for back button - button stays in place */
    .auth-container {
        padding-top: 100px;  /* Extra padding to push content below the back button */
        align-items: flex-start;  /* Align to top instead of center on mobile */
    }
    
    .about-card {
        max-width: 100%;
        padding: 20px;
    }
    
    /* Back button stays in same position, just make it smaller on mobile */
    .about-back-btn {
        left: 10px;
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .about-section__title {
        font-size: 22px;
    }
    
    .about-section__text {
        font-size: 16px;
    }
    
    .team-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Adjust top bar for mobile - shift content right to avoid button overlap */
    .top-bar__content {
        margin-left: 50px;  /* Make room for the i button on the left */
    }
    
    .top-bar__text--primary {
        font-size: 36px;
    }
    
    /* Scale logo down for mobile */
    .top-bar__logo {
        height: 60px;
    }
    
    .top-bar__text--secondary {
        font-size: 24px;
    }
    
    /* Make help button smaller and closer to edge on mobile */
    .top-bar__help-btn {
        left: 8px;          /* Closer to left edge */
        width: 32px;        /* Smaller button */
        height: 32px;
        font-size: 16px;    /* Smaller text */
    }
    
    /* Make logout button same size as help button on mobile */
    .top-bar__logout-btn {
        right: 8px;         /* Closer to right edge */
        width: 32px;        /* Match help button size */
        height: 32px;
        font-size: 16px;    /* Match help button text size */
    }

}
