:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --sidebar-bg: #111827;
    --input-bg: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --transition: 0.2s ease-in-out;
}

/* Light Mode Theme */
:root[data-theme="light"] {
    --background: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --sidebar-bg: #ffffff;
    --input-bg: #f8fafc;
    
    /* Keep primary colors but adjust if needed */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-overlay.active {
    display: flex;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    padding: 2.5rem 2rem 1.5rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(99,102,241,0.05));
    border-bottom: 1px solid var(--border-color);
}

.login-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: block;
}

.login-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.login-header p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.login-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-error {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
}

.login-btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-container.visible {
    opacity: 1;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.5rem;
}

.sidebar-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-btn i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-btn:hover {
    background-color: var(--surface);
    color: var(--text-primary);
}

.nav-btn.active {
    background-color: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
}

.footer-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.footer-btn.theme-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    font-size: 0.95rem;
}

.footer-btn.theme-toggle:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

.footer-btn.logout-btn {
    flex: 1;
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.footer-btn.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    transition: var(--transition);
}

.status-dot.connected {
    background-color: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    width: calc(100% - 260px);
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: default;
}

.header-stat i {
    font-size: 0.875rem;
    color: var(--primary);
}

.header-stat:first-child i { color: var(--info); }
.header-stat:last-child i { color: var(--success); }

.current-time {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card.active-calls .stat-icon { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-card.success-rate .stat-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-card.system-status .stat-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.ok {
    color: var(--success);
    font-size: 1.25rem;
}

.stat-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Dashboard Section */
.dashboard-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-link {
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Pages Styling */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

/* Stats Strip (For CDR Page) */
.stats-strip {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.mini-stat {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--border-color);
}

.mini-stat:last-child {
    border: none;
}

.mini-stat .label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mini-stat .value {
    font-weight: 700;
    font-size: 1.125rem;
}

.mini-stat.success .value { color: var(--success); }
.mini-stat.failed .value { color: var(--danger); }

/* Filters */
.filters-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.filters-section h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.date-range-inputs {
    display: flex;
    gap: 0.5rem;
}

.date-range-inputs input {
    flex: 1;
    min-width: 0;
}

input, select {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
}

/* Filters Responsive */
@media (max-width: 1200px) {
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-actions {
        grid-column: span 2;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .filters-section {
        padding: 1rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .filter-actions {
        grid-column: span 1;
        flex-direction: row;
        width: 100%;
    }

    .filter-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .date-range-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Tables */
.table-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-container {
    overflow-x: auto;
}

.calls-table {
    width: 100%;
    border-collapse: collapse;
}

.calls-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

.calls-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.calls-table tr:hover {
    background: var(--surface-hover);
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.status-badge.active { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.status-badge.answered { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-badge.failed { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.status-badge.cancelled { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); }
.status-badge.busy { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

/* Dongles Grid */
.dongles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dongle-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    transition: var(--transition);
}

.dongle-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.dongle-card.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.dongle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-left: 30px; /* Space for checkbox */
}

.dongle-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dongle-info {
    display: grid;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.info-label { color: var(--text-secondary); }
.info-value { font-weight: 500; font-family: monospace; }

/* Signal Bar */
.signal-container {
    margin-top: 1rem;
}

.signal-bar-bg {
    height: 6px;
    background: var(--surface-hover);
    border-radius: 3px;
    overflow: hidden;
}

.signal-bar-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.5s ease;
}

.signal-bar-fill.medium { background: var(--warning); }
.signal-bar-fill.low { background: var(--danger); }

/* Checkbox */
.dongle-select-checkbox {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
    opacity: 0.7;
    z-index: 10;
}

.dongle-card:hover .dongle-select-checkbox,
.dongle-card.selected .dongle-select-checkbox {
    opacity: 1;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    gap: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface-hover);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; padding: 1rem; }

    .top-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .stats-strip {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .mini-stat {
        border-right: none;
        padding-right: 0;
        flex: 1;
        min-width: calc(50% - 0.5rem);
        padding: 0.5rem;
        background: var(--input-bg);
        border-radius: var(--radius);
        justify-content: center;
    }

    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .pagination-controls {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ===========================
   Audio Player Modal
   =========================== */
.recording-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.recording-modal.active {
    display: flex; /* Ensure flex is applied when active class is added */
}

.recording-modal-content {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    animation: scaleUp 0.3s forwards;
}

@keyframes scaleUp { to { transform: scale(1); opacity: 1; } }

.recording-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.recording-modal-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.close-modal:hover { color: var(--danger); transform: rotate(90deg); }

.recording-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: var(--radius);
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.info-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 1.1rem;
}

/* Audio Player Controls */
.audio-player {
    background: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.waveform {
    height: 60px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.progress-bar {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
    width: 0%;
    transition: width 0.1s linear;
    opacity: 0.5;
}

.seek-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.audio-time {
    display: flex;
    justify-content: space-between;
    font-family: monospace;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.audio-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.3);
}

.control-btn:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.volume-slider {
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-hover);
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.speed-select {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.download-btn {
    padding: 0.5rem 1rem;
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

.download-btn:hover {
    background: var(--border-color);
    color: var(--primary);
}
/* Circular Progress */
.progress-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0%, var(--surface-hover) 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.5s ease;
}

.inner-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}


/* Login Page */
.login-container {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    background: var(--background); /* Solid background to hide content behind */
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.login-container.active { display: flex; }
.login-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    width: 100%; max-width: 400px;
    border: 1px solid var(--border-color);
    text-align: center;
}
.login-title { margin-bottom: 2rem; color: var(--text-primary); }
.login-input {
    width: 100%; padding: 0.8rem 1rem; margin-bottom: 1rem;
    background: var(--input-bg); border: 1px solid var(--border-color);
    border-radius: var(--radius); color: var(--text-primary);
}
.login-btn { width: 100%; padding: 0.8rem; margin-top: 1rem; }


.status-dot.busy { background: var(--warning); }
.status-dot.in-call { background: #d946ef; box-shadow: 0 0 8px #d946ef; animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* ===========================
   USSD Tools Page
   =========================== */
.ussd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 968px) {
    .ussd-grid { grid-template-columns: 1fr; }
}

.ussd-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.3s;
}

.ussd-card:hover {
    border-color: var(--primary);
}

.ussd-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(99,102,241,0.1));
    border-bottom: 1px solid var(--border-color);
}

.ussd-card-header i {
    font-size: 1.5rem;
    color: var(--primary);
}

.ussd-card-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.ussd-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(99,102,241,0.15);
    color: var(--primary);
}

.ussd-badge.wallet {
    background: rgba(16,185,129,0.15);
    color: var(--success);
}

.ussd-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.ussd-select, .ussd-input {
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.ussd-select:focus, .ussd-input:focus {
    border-color: var(--primary);
}

.ussd-select option {
    background: var(--surface);
    color: var(--text-primary);
}

.ussd-presets {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ussd-presets label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: 'Inter', monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.1);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.preset-btn img {
    width: 16px;
    height: 16px;
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.input-with-btn .ussd-input {
    flex: 1;
}

.input-with-btn .btn {
    white-space: nowrap;
}

.ussd-result {
    min-height: 80px;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    overflow-wrap: break-word;
    word-break: break-word;
    transition: all 0.3s;
}

.ussd-result.has-data {
    border-style: solid;
    border-color: var(--success);
    background: rgba(16,185,129,0.05);
}

.ussd-result.error {
    border-color: var(--danger);
    background: rgba(239,68,68,0.05);
    color: var(--danger);
}

.ussd-result.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-muted);
    border-color: var(--primary);
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    padding: 1rem;
}

.result-placeholder i {
    font-size: 1.5rem;
    opacity: 0.5;
}

/* USSD History */
.ussd-history-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
}

.ussd-history-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ussd-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.ussd-history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border-radius: var(--radius);
    font-size: 0.85rem;
    direction: rtl;
}

.ussd-history-item .history-dongle {
    font-weight: 600;
    color: var(--primary);
    min-width: 70px;
}

.ussd-history-item .history-code {
    font-family: monospace;
    color: var(--text-muted);
    min-width: 60px;
    direction: ltr;
}

.ussd-history-item .history-response {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ussd-history-item .history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 50px;
    direction: ltr;
}
