/* ═══════════════════════════════════════════════════
   F9 Recordings — Dark Theme Premium Design System
   ═══════════════════════════════════════════════════ */

:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-elevated: #1c1c28;
    --bg-hover: #22222f;
    --bg-input: #1a1a25;

    --border: #2a2a3a;
    --border-focus: #4f46e5;

    --text-primary: #e8e8ed;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Spacing */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 24px var(--accent-glow);
}

/* ─── Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 90px;
    overflow-x: hidden;
}

/* ─── Header ─────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo .accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-bar {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-hover);
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-elevated);
    font-size: 12px;
    color: var(--text-secondary);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.sync-dot.syncing {
    background: var(--warning);
    box-shadow: 0 0 6px var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ─── Warning Banner ─────────────────────────────── */
.warning-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    background: rgba(245, 158, 11, 0.1);
    border-bottom: 1px solid rgba(245, 158, 11, 0.25);
}

.warning-banner .warning-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.warning-banner p {
    font-size: 13px;
    color: #fbbf24;
    line-height: 1.4;
}

.warning-banner p strong {
    color: #fcd34d;
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 18px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-sync {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-sync:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 0 32px var(--accent-glow);
}

.btn-sync.syncing .icon-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.btn-search {
    background: var(--accent);
    color: white;
    padding: 10px 24px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 14px;
}

.btn-search:hover {
    background: var(--accent-hover);
}

.btn-clear {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-clear:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ─── Search Section ─────────────────────────────── */
.search-section {
    max-width: 1200px;
    margin: 28px auto 0;
    padding: 0 28px;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.search-icon {
    padding: 0 4px 0 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    padding: 14px 12px;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.filters {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 500;
}

.filter-group select,
.filter-group input[type="date"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    min-width: 150px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input[type="date"]:focus {
    border-color: var(--accent);
}

/* ─── Results ────────────────────────────────────── */
.results-section {
    max-width: 1200px;
    margin: 24px auto 0;
    padding: 0 28px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.results-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

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

.recordings-table thead {
    background: var(--bg-elevated);
}

.recordings-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.recordings-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    color: var(--text-secondary);
}

.recordings-table tbody tr {
    transition: background 0.15s ease;
}

.recordings-table tbody tr:hover {
    background: var(--bg-hover);
}

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

td.phone-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
    color: var(--accent-hover);
    font-size: 13px;
    letter-spacing: 0.3px;
}

td.disposition-cell .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    white-space: nowrap;
}

td.size-cell {
    color: var(--text-muted);
    font-size: 12px;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-action:hover {
    border-color: var(--accent);
    color: var(--accent-hover);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.btn-action.play:hover {
    border-color: var(--success);
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.btn-action.download:hover {
    border-color: var(--info);
    color: var(--info);
    background: rgba(59, 130, 246, 0.1);
}

.btn-action.loading {
    pointer-events: none;
    opacity: 0.5;
}

.btn-action.loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    position: absolute;
}

/* ─── Empty State ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

/* ─── Pagination ─────────────────────────────────── */
.pagination,
.pagination-bottom {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pagination-bottom {
    margin-top: 16px;
    justify-content: center;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent-hover);
}

.page-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.page-info {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* ─── Audio Player Bar ───────────────────────────── */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 200;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

.player-bar.active {
    transform: translateY(0);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.player-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.player-details {
    display: flex;
    flex-direction: column;
}

.player-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.player-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.player-controls {
    flex: 1;
    display: flex;
    justify-content: center;
}

.player-controls audio {
    width: 100%;
    max-width: 500px;
    height: 36px;
    filter: invert(1) hue-rotate(180deg) brightness(0.85);
}

.btn-player-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-player-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* ─── Loading Overlay ────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.overlay p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-left {
        flex-direction: column;
        gap: 8px;
    }

    .stats-bar {
        gap: 16px;
    }

    .search-section,
    .results-section {
        padding: 0 12px;
    }

    .filters {
        flex-direction: column;
        gap: 8px;
    }

    .filter-group select,
    .filter-group input[type="date"] {
        min-width: unset;
        width: 100%;
    }

    .table-wrapper {
        overflow-x: auto;
    }

    .recordings-table {
        min-width: 700px;
    }

    .player-bar {
        flex-direction: column;
        padding: 10px 16px;
        gap: 10px;
    }

    .player-info {
        min-width: unset;
        width: 100%;
    }

    .player-controls {
        width: 100%;
    }

    .player-controls audio {
        max-width: 100%;
    }
}

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

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

/* ─── Toast Notifications ────────────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--info);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(50%);
    }
}