/* ================================================== */
/* RO-GenesysPhoneAssignment - Dual Theme + Fluid UI  */
/* ================================================== */

/* ================================================== */
/* Light Theme (default)                               */
/* ================================================== */

:root {
    /* Fluid typography — scales with viewport, no hard cap */
    --text-xs: clamp(0.7rem, 0.4rem + 0.5vw, 1.5rem);
    --text-sm: clamp(0.8rem, 0.45rem + 0.6vw, 1.75rem);
    --text-base: clamp(0.875rem, 0.5rem + 0.7vw, 2rem);
    --text-lg: clamp(1rem, 0.55rem + 0.85vw, 2.5rem);
    --text-xl: clamp(1.25rem, 0.6rem + 1vw, 3rem);

    /* Fluid spacing — scales with viewport */
    --space-xs: clamp(0.25rem, 0.1rem + 0.3vw, 1rem);
    --space-sm: clamp(0.5rem, 0.2rem + 0.5vw, 1.5rem);
    --space-md: clamp(0.75rem, 0.3rem + 0.7vw, 2rem);
    --space-lg: clamp(1rem, 0.4rem + 1vw, 3rem);
    --space-xl: clamp(1.25rem, 0.5rem + 1.2vw, 4rem);
    --container-padding: clamp(1rem, 2vw, 6rem);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Backgrounds */
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-header: #0f172a;
    --bg-input: #ffffff;

    /* Borders */
    --border-default: #e2e8f0;
    --border-subtle: #f1f5f9;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-on-header: #f8fafc;

    /* Accent colors */
    --accent-blue: #0ea5e9;
    --accent-blue-hover: #0284c7;
    --accent-cyan: #06b6d4;
    --accent-teal: #14b8a6;
    --accent-pink: #ec4899;
    --accent-red: #ef4444;

    /* Functional */
    --color-primary: var(--accent-blue);
    --color-primary-hover: var(--accent-blue-hover);
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: var(--accent-red);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);

    /* Status messages */
    --status-success-bg: #ecfdf5;
    --status-success-text: #065f46;
    --status-success-border: #a7f3d0;
    --status-error-bg: #fef2f2;
    --status-error-text: #991b1b;
    --status-error-border: #fecaca;
    --status-info-bg: #f0f9ff;
    --status-info-text: #075985;
    --status-info-border: #bae6fd;

    /* Alerts */
    --alert-warning-bg: #fffbeb;
    --alert-warning-text: #b45309;
    --alert-warning-border: var(--color-warning);
    --alert-info-bg: #f0f9ff;
    --alert-info-text: #0369a1;
    --alert-info-border: var(--accent-blue);

    /* Modal */
    --modal-overlay: rgba(0,0,0,0.4);
    --modal-bg: var(--bg-surface);

    /* Buttons */
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-text: #334155;
    --btn-secondary-hover: #cbd5e1;

    /* Table */
    --table-header-bg: #f8fafc;
    --table-row-hover: #f1f5f9;
    --table-border: #e2e8f0;

    /* Spinner */
    --spinner-track: #e2e8f0;
    --spinner-accent: var(--color-primary);

    /* Focus */
    --focus-ring: rgba(14,165,233,0.25);

    /* Card accent */
    --card-accent: var(--accent-cyan);
}

/* ================================================== */
/* Dark Theme                                          */
/* ================================================== */

[data-theme="dark"] {
    color-scheme: dark;

    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-header: #0f172a;
    --bg-input: #1e293b;

    --border-default: #334155;
    --border-subtle: #1e293b;

    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;

    --accent-blue: #38bdf8;
    --accent-blue-hover: #0ea5e9;
    --accent-cyan: #22d3ee;
    --accent-teal: #2dd4bf;
    --accent-pink: #f472b6;
    --accent-red: #f87171;

    --color-primary: var(--accent-blue);
    --color-primary-hover: var(--accent-blue-hover);
    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-danger: var(--accent-red);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.2);

    --status-success-bg: rgba(16,185,129,0.15);
    --status-success-text: #6ee7b7;
    --status-success-border: rgba(16,185,129,0.3);
    --status-error-bg: rgba(239,68,68,0.15);
    --status-error-text: #fca5a5;
    --status-error-border: rgba(239,68,68,0.3);
    --status-info-bg: rgba(14,165,233,0.15);
    --status-info-text: #7dd3fc;
    --status-info-border: rgba(14,165,233,0.3);

    --alert-warning-bg: rgba(245,158,11,0.15);
    --alert-warning-text: #fcd34d;
    --alert-warning-border: var(--color-warning);
    --alert-info-bg: rgba(14,165,233,0.15);
    --alert-info-text: #7dd3fc;
    --alert-info-border: var(--accent-blue);

    --modal-overlay: rgba(0,0,0,0.6);
    --modal-bg: var(--bg-surface);

    --btn-secondary-bg: #334155;
    --btn-secondary-text: #e2e8f0;
    --btn-secondary-hover: #475569;

    --table-header-bg: #1e293b;
    --table-row-hover: #334155;
    --table-border: #334155;

    --spinner-track: #334155;

    --focus-ring: rgba(56,189,248,0.35);

    --card-accent: var(--accent-cyan);
}

/* ================================================== */
/* Reset & Base                                        */
/* ================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-body);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================================================== */
/* Header                                              */
/* ================================================== */

.header {
    background-color: var(--bg-header);
    color: var(--text-on-header);
    padding: 0 var(--container-padding);
    height: clamp(3rem, 1.5rem + 2.5vw, 6rem);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.header-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-img {
    height: clamp(1.25rem, 0.5rem + 1.2vw, 3rem);
    filter: brightness(0) invert(1);
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.page-title {
    font-size: var(--text-base);
    font-weight: 500;
    opacity: 0.85;
    white-space: nowrap;
}

.header-right {
    flex-shrink: 0;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ================================================== */
/* Theme Toggle                                        */
/* ================================================== */

.theme-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-on-header);
    width: clamp(1.75rem, 1rem + 1.2vw, 4rem);
    height: clamp(1.75rem, 1rem + 1.2vw, 4rem);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}

.theme-toggle svg {
    width: clamp(0.875rem, 0.4rem + 0.8vw, 2.25rem);
    height: clamp(0.875rem, 0.4rem + 0.8vw, 2.25rem);
}

/* Light mode: show moon (click to go dark) */
.icon-sun { display: none; }
.icon-moon { display: block; }

/* Dark mode: show sun (click to go light) */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ================================================== */
/* Avatar                                              */
/* ================================================== */

.user-avatar {
    width: clamp(1.625rem, 0.8rem + 1.2vw, 3.5rem);
    height: clamp(1.625rem, 0.8rem + 1.2vw, 3.5rem);
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255,255,255,0.4);
}

.user-initials {
    width: clamp(1.625rem, 0.8rem + 1.2vw, 3.5rem);
    height: clamp(1.625rem, 0.8rem + 1.2vw, 3.5rem);
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: var(--text-on-header);
    font-size: var(--text-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255,255,255,0.4);
}

/* ================================================== */
/* Container                                           */
/* ================================================== */

.container {
    width: 100%;
    padding: var(--space-lg) var(--container-padding);
}

/* ================================================== */
/* Current Phone Card                                  */
/* ================================================== */

.current-phone-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--card-accent);
    margin-bottom: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.current-phone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.current-phone-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.current-phone-value {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.current-phone-value.no-phone {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

/* ================================================== */
/* Status Messages                                     */
/* ================================================== */

.status-message {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    font-size: var(--text-base);
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.status-message.success {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
    border: 1px solid var(--status-success-border);
}

.status-message.error {
    background-color: var(--status-error-bg);
    color: var(--status-error-text);
    border: 1px solid var(--status-error-border);
}

.status-message.info {
    background-color: var(--status-info-bg);
    color: var(--status-info-text);
    border: 1px solid var(--status-info-border);
}

/* ================================================== */
/* Filter Bar                                          */
/* ================================================== */

.filter-bar {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-sm) var(--space-lg);
    margin-bottom: var(--space-md);
    transition: background-color 0.3s ease;
}

.filter-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filter-group label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.branch-select {
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    min-width: clamp(180px, 10vw + 60px, 500px);
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
}

.branch-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-count {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

/* ================================================== */
/* Loading                                             */
/* ================================================== */

.loading-spinner {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    color: var(--text-muted);
}

.spinner {
    width: clamp(1.5rem, 0.8rem + 1vw, 3.5rem);
    height: clamp(1.5rem, 0.8rem + 1vw, 3.5rem);
    border: 3px solid var(--spinner-track);
    border-top-color: var(--spinner-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto var(--space-sm);
}

.spinner-inline {
    width: 14px;
    height: 14px;
    border: 2px solid var(--spinner-track);
    border-top-color: var(--spinner-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: var(--space-xs);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================== */
/* Phones Table                                        */
/* ================================================== */

.phones-section {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--space-lg);
    transition: background-color 0.3s ease;
}

.phones-table {
    width: 100%;
    border-collapse: collapse;
}

.phones-table thead {
    background-color: var(--table-header-bg);
    border-bottom: 1px solid var(--table-border);
}

.phones-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.phones-table tbody tr {
    border-bottom: 1px solid var(--table-border);
    transition: background-color 0.15s;
}

.phones-table tbody tr:last-child {
    border-bottom: none;
}

.phones-table tbody tr:hover {
    background-color: var(--table-row-hover);
}

.phones-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
}

.phones-table td.text-center {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-xl) var(--space-md);
}

.phone-name {
    font-weight: 600;
    color: var(--text-primary);
}

.phone-user {
    color: var(--text-secondary);
    text-align: center;
}

.phone-user.unassigned {
    color: var(--text-muted);
    font-style: italic;
}

.phone-action {
    text-align: center;
}

.phones-table th:first-child,
.phones-table td:first-child {
    width: 20%;
    text-align: center;
}

.phones-table th:nth-child(2),
.phones-table td:nth-child(2) {
    width: 60%;
    text-align: center;
}

.phones-table th:last-child,
.phones-table td:last-child {
    width: 20%;
    text-align: center;
}

/* ================================================== */
/* Buttons                                             */
/* ================================================== */

.btn {
    padding: var(--space-xs) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--btn-secondary-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: clamp(0.25rem, 0.2rem + 0.1vw, 0.375rem) var(--space-sm);
    font-size: var(--text-xs);
}

.assign-btn {
    white-space: nowrap;
}

/* ================================================== */
/* Modal                                               */
/* ================================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.15s;
}

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

.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: min(clamp(400px, 20vw + 200px, 800px), 90vw);
    width: 90%;
    animation: slideUp 0.2s;
}

@keyframes slideUp {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-xl);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: clamp(26px, 1rem + 0.5vw, 48px);
    height: clamp(26px, 1rem + 0.5vw, 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

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

.modal-body {
    padding: var(--space-md) var(--space-lg);
}

.modal-body p {
    margin: var(--space-xs) 0;
    font-size: var(--text-base);
    color: var(--text-secondary);
}

.modal-footer {
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--border-default);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.modal-progress {
    max-width: clamp(260px, 12vw + 120px, 500px);
    text-align: center;
}

.modal-progress .modal-body {
    padding: var(--space-xl) var(--space-lg);
}

/* ================================================== */
/* Alerts                                              */
/* ================================================== */

.info,
.warning {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin: var(--space-sm) 0;
    font-size: var(--text-sm);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.info {
    background-color: var(--alert-info-bg);
    color: var(--alert-info-text);
    border-left: 3px solid var(--alert-info-border);
}

.warning {
    background-color: var(--alert-warning-bg);
    color: var(--alert-warning-text);
    border-left: 3px solid var(--alert-warning-border);
}

/* ================================================== */
/* No Phones / Helpers                                 */
/* ================================================== */

.no-phones {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
}

.no-phones p {
    font-size: var(--text-base);
    margin: var(--space-xs) 0;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

/* ================================================== */
/* Footer                                              */
/* ================================================== */

.footer {
    text-align: center;
    padding: var(--space-md) var(--space-lg);
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ================================================== */
/* Responsive                                          */
/* ================================================== */

@media (max-width: 600px) {
    .header-center {
        display: none;
    }

    .filter-bar-inner {
        flex-wrap: wrap;
    }

    .filter-group {
        width: 100%;
    }

    .branch-select {
        width: 100%;
        min-width: unset;
    }

    .filter-count {
        width: 100%;
        text-align: right;
    }
}
