/* =========================================================
   VoIP GO — Stylesheet (refresh)
   Professional, minimal, accessible. Same class API as before.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* ----- Dark theme (default) ----- */
    --bg-main:       #0b0c0f;
    --bg-sidebar:    #111317;
    --bg-card:       #15171c;
    --bg-card-2:     #181b21;
    --bg-modal:      #15171c;
    --bg-glass:      rgba(255, 255, 255, 0.04);
    --bg-tertiary:   #1c1f25;
    --bg-input:      #0f1115;
    --bg-hover:      rgba(255, 255, 255, 0.05);

    --primary:       #6366f1;   /* indigo-500 */
    --primary-hover: #4f46e5;   /* indigo-600 */
    --primary-light: #818cf8;   /* indigo-400 */
    --primary-glow:  rgba(99, 102, 241, 0.18);
    --primary-soft:  rgba(99, 102, 241, 0.12);

    --secondary:     #ec4899;
    --accent:        #06b6d4;

    --success:       #10b981;
    --success-soft:  rgba(16, 185, 129, 0.14);
    --danger:        #ef4444;
    --danger-soft:   rgba(239, 68, 68, 0.14);
    --warning:       #f59e0b;
    --warning-soft:  rgba(245, 158, 11, 0.14);
    --info:          #3b82f6;
    --info-soft:     rgba(59, 130, 246, 0.14);

    --text-main:      #e5e7eb;
    --text-primary:   #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted:     #6b7280;
    --text-inverse:   #0b0c0f;

    --border-light:  rgba(255, 255, 255, 0.06);
    --border-color:  rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);

    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-card:  0 1px 0 rgba(255,255,255,0.02) inset, 0 6px 24px rgba(0, 0, 0, 0.25);
    --shadow-modal: 0 30px 60px rgba(0, 0, 0, 0.55);
    --shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.25);

    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 248px;

    --bg-gradient: none;
}

[data-theme="light"] {
    --bg-main:       #f6f7f9;
    --bg-sidebar:    #ffffff;
    --bg-card:       #ffffff;
    --bg-card-2:     #fbfbfc;
    --bg-modal:      #ffffff;
    --bg-glass:      rgba(0, 0, 0, 0.03);
    --bg-tertiary:   #f1f3f5;
    --bg-input:      #ffffff;
    --bg-hover:      rgba(0, 0, 0, 0.04);

    --primary:       #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #6366f1;
    --primary-glow:  rgba(79, 70, 229, 0.16);
    --primary-soft:  rgba(79, 70, 229, 0.10);

    --text-main:      #111827;
    --text-primary:   #0f172a;
    --text-secondary: #4b5563;
    --text-muted:     #6b7280;
    --text-inverse:   #ffffff;

    --border-light:  rgba(15, 23, 42, 0.06);
    --border-color:  rgba(15, 23, 42, 0.10);
    --border-strong: rgba(15, 23, 42, 0.18);

    --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card:  0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-modal: 0 25px 50px rgba(15, 23, 42, 0.18);
    --shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.18);

    --bg-gradient: none;
}

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

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

::selection { background: var(--primary-soft); color: var(--text-primary); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid var(--bg-main);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.75rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-primary);
    margin: 0.25rem 0.75rem 1.5rem;
}

.brand i {
    color: var(--primary);
    font-size: 1.35rem;
    filter: none;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.25rem;
}

.nav-item {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item i {
    font-size: 1.05rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item:hover i { color: var(--text-primary); }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary-light);
    transform: none;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.75rem 0.25rem;
    border-top: 1px solid var(--border-light);
}

/* ---------- Main ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem 3rem;
    max-width: 1600px;
    width: calc(100% - var(--sidebar-width));
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.15rem;
}

/* ---------- Status pills ---------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.status-connected .status-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-disconnected .status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-connected { color: var(--success); }
.status-disconnected { color: var(--danger); }

/* ---------- Cards ---------- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.glass-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ---------- Grids ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: var(--transition);
}

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

.form-control:hover:not(:focus):not(:disabled) {
    border-color: var(--border-strong);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.form-control:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 90px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.4;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }

.btn i { font-size: 1em; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #059669; border-color: #059669; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) { background: #d97706; border-color: #d97706; }

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; gap: 0.35rem; }
.btn-lg { padding: 0.75rem 1.4rem; font-size: 0.95rem; }

/* ---------- Call interface ---------- */
.call-status-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    position: relative;
}

.ripple-wrapper {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    background: var(--success);
    border-radius: 50%;
}

.ripple {
    position: absolute;
    inset: 0;
    background: var(--success);
    border-radius: 50%;
    opacity: 0;
}

.call-active .ripple { animation: ripple-anim 2s infinite; }
.call-active .ripple:nth-child(2) { animation-delay: 0.5s; }
.call-active .ripple:nth-child(3) { animation-delay: 1s; }

@keyframes ripple-anim {
    0%   { transform: scale(1);   opacity: 0.4; }
    100% { transform: scale(2.4); opacity: 0;   }
}

.call-icon-large {
    font-size: 2.4rem;
    color: #fff;
    z-index: 2;
    position: relative;
}

.timer {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* ---------- Tables ---------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 0.7rem 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-card-2);
    border-bottom: 1px solid var(--border-light);
}

.table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover td { background: var(--bg-hover); }

/* Action button cells: keep buttons inline + tight gap */
.table td .btn.btn-sm {
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
}
.table td .btn + .btn { margin-left: 0.25rem; }
.table td.actions-cell,
.table td:has(.btn-sm + .btn-sm) {
    white-space: nowrap;
    text-align: right;
}

/* ---------- Tabs ---------- */
.tab-content {
    display: none;
    animation: fadeIn 0.18s ease;
}
.tab-content.active { display: block; }

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

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeOverlay 0.18s ease;
}

[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.45); }

.modal-overlay.show,
.modal-overlay.active { display: flex; }

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

.modal-card {
    background: var(--bg-modal);
    width: 100%;
    max-width: 640px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    animation: slideUp 0.2s ease;
    color: var(--text-main);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3,
.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    background: var(--bg-card-2);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ---------- Sub-tabs (Campaigns / Mailings) ---------- */
.subtabs-container {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0;
}

.subtab-btn {
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: -1px;
}

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

.subtab-btn.active {
    background: transparent;
    color: var(--primary-light);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.subtab-content { display: none; }
.subtab-content.active { display: block; }

/* ---------- Campaign status pills ---------- */
.campaign-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}

.campaign-status.draft     { background: var(--bg-tertiary);   color: var(--text-muted);  border-color: var(--border-light); }
.campaign-status.running   { background: var(--success-soft);  color: var(--success);     border-color: rgba(16,185,129,0.25); }
.campaign-status.paused    { background: var(--warning-soft);  color: var(--warning);     border-color: rgba(245,158,11,0.25); }
.campaign-status.completed { background: var(--info-soft);     color: var(--info);        border-color: rgba(59,130,246,0.25); }
.campaign-status.pending   { background: var(--bg-tertiary);   color: var(--text-muted);  border-color: var(--border-light); }
.campaign-status.calling   { background: var(--primary-soft);  color: var(--primary-light); border-color: rgba(99,102,241,0.25); }
.campaign-status.answered  { background: var(--success-soft);  color: var(--success);     border-color: rgba(16,185,129,0.25); }
.campaign-status.failed    { background: var(--danger-soft);   color: var(--danger);      border-color: rgba(239,68,68,0.25); }

/* ---------- Progress bars ---------- */
.progress-bar-campaign {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.4rem;
}

.progress-bar-campaign .progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.progress-bar-sm {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    min-width: 80px;
}

.progress-bar-sm .progress-fill {
    height: 100%;
    background: var(--primary);
}

/* ---------- Stats grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    text-align: left;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ---------- Mailings import ---------- */
.import-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.import-tab-btn {
    padding: 0.45rem 0.9rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
}

.import-tab-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }

.import-tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.import-panel { display: none; }
.import-panel.active { display: block; }

.import-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card-2);
    color: var(--text-secondary);
}

.import-area:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--text-primary); }
.import-area.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--text-primary); }

/* ---------- Contact preview ---------- */
.contact-preview {
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin-top: 0.85rem;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ---------- Range slider ---------- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    cursor: pointer;
    border: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 2px solid var(--bg-main);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px var(--primary-soft);
}

input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.05); }

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 2px solid var(--bg-main);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-sm);
}

.slider-value-badge {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary-light);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 56px;
    text-align: center;
    border: 1px solid var(--border-light);
}

/* ---------- SIP status bar ---------- */
.sip-status-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card-2);
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid var(--danger);
    padding: 0.65rem 1.25rem;
    margin: -1.5rem -2rem 1.25rem;
    transition: border-left-color 0.2s ease, background 0.2s ease;
}

.sip-status-bar.connected { border-left-color: var(--success); }

.sip-status-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.sip-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-dot-large {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
    animation: pulse-soft 2s infinite;
}

.sip-status-bar.connected .status-dot-large {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 0 0 3px var(--danger-soft); }
    50%      { box-shadow: 0 0 0 6px var(--danger-soft); }
}

.sip-status-bar.connected .status-dot-large {
    animation: pulse-soft-success 2s infinite;
}

@keyframes pulse-soft-success {
    0%, 100% { box-shadow: 0 0 0 3px var(--success-soft); }
    50%      { box-shadow: 0 0 0 6px var(--success-soft); }
}

.sip-status-text {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--danger);
}

.sip-status-bar.connected .sip-status-text { color: var(--success); }

.sip-status-details { font-size: 0.8rem; color: var(--text-muted); }

.sip-status-details strong { color: var(--text-primary); font-weight: 600; }

/* ---------- Code styling ---------- */
code {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    color: var(--primary-light);
    border: 1px solid var(--border-light);
}

/* ---------- Tool rows (agent tools) ---------- */
.tool-row,
.tool-card {
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

/* ---------- Utility classes ---------- */
.d-none { display: none !important; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-inline-block { display: inline-block; }

.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow-1 { flex-grow: 1; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }

.px-3 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.text-center { text-align: center; }
.text-end    { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.fs-sm { font-size: 0.8rem; }
.fs-lg { font-size: 1rem; }

.rounded-pill { border-radius: 999px; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 100%; }
    .app-container { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 0.75rem;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .nav-links {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.25rem;
        gap: 0.25rem;
    }

    .nav-item {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .nav-item.active {
        border-left: none;
        border-bottom-color: var(--primary);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
    }

    .grid-2,
    .grid-3 { grid-template-columns: 1fr; }

    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .sidebar-footer { display: none; }

    .sip-status-bar { margin: -1rem -1rem 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .modal-card { max-width: 100%; }
}

/* =========================================================
   Call mode toggle (AI vs Voice softphone)
   ========================================================= */
.call-mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    padding: 0.35rem;
    border-radius: var(--radius-md);
}

.call-mode-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    font-family: inherit;
}

.call-mode-btn i {
    font-size: 1.25rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.call-mode-btn .cm-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
}

.call-mode-btn .cm-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.1;
}

.call-mode-btn:hover {
    background: var(--bg-hover);
}

.call-mode-btn.active {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.call-mode-btn.active i,
.call-mode-btn.active .cm-title {
    color: var(--primary-light);
}

/* Voice call control panel */
.voice-controls {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1rem;
}
.voice-control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--bg-card-2);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}
.voice-control-btn:hover { background: var(--bg-hover); }
.voice-control-btn.active {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}
.voice-meter {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    margin-top: 1rem;
    overflow: hidden;
}
.voice-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    width: 0%;
    transition: width 80ms linear;
}

/* =========================================================
   History (call log) page
   ========================================================= */
.history-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.history-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    transition: var(--transition);
}
.history-kpi:hover { background: var(--bg-card-2); }
.history-kpi-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}
.history-kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.history-kpi-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.history-filters {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.85rem 1rem !important;
    flex-wrap: wrap;
}
.history-filters .hf-search {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.history-filters .hf-search input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
}
.history-filters .hf-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card-2);
}
.history-filters .hf-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.history-table tbody tr { cursor: pointer; }
.history-table .dir-badge {
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
}
.history-table .dir-out { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.history-table .dir-in  { background: rgba(16,185,129,0.15); color: var(--success); }
.history-table .num-col { font-variant-numeric: tabular-nums; font-weight: 500; }
.history-table .ring-col, .history-table .dur-col { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-size: 0.85rem; }

.history-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.history-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.history-status.s-answered  { background: var(--success-soft); color: var(--success); }
.history-status.s-ended     { background: var(--info-soft);    color: var(--info); }
.history-status.s-no_answer { background: var(--warning-soft); color: var(--warning); }
.history-status.s-failed    { background: var(--danger-soft);  color: var(--danger); }
.history-status.s-ringing,
.history-status.s-initiated { background: var(--primary-soft); color: var(--primary-light); }

/* =========================================================
   Call Chat Modal (conversation transcript)
   ========================================================= */
.chat-modal-card {
    max-width: 720px;
    width: 95%;
    height: min(85vh, 800px);
    display: flex;
    flex-direction: column;
}
.chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.chat-modal-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}
.chat-modal-meta .meta-pill {
    display: inline-block;
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    padding: 0.12rem 0.5rem;
    border-radius: var(--radius-xs);
    font-variant-numeric: tabular-nums;
    margin-right: 0.25rem;
}
.chat-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem !important;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.chat-bubble-row {
    display: flex;
    margin-bottom: 0.6rem;
    gap: 0.5rem;
    align-items: flex-end;
}
.chat-bubble-row.user { justify-content: flex-end; }
.chat-bubble-row.ai   { justify-content: flex-start; }
.chat-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: #fff;
}
.chat-bubble-row.ai   .chat-avatar { background: var(--primary); }
.chat-bubble-row.user .chat-avatar { background: var(--success); order: 2; }
.chat-bubble {
    max-width: 70%;
    padding: 0.55rem 0.85rem;
    border-radius: 14px;
    line-height: 1.4;
    font-size: 0.9rem;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.chat-bubble-row.ai .chat-bubble {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}
.chat-bubble-row.user .chat-bubble {
    background: var(--success);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-time {
    display: block;
    font-size: 0.65rem;
    margin-top: 0.25rem;
    opacity: 0.65;
}
.chat-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.chat-empty i { font-size: 3rem; opacity: 0.3; display: block; margin-bottom: 0.5rem; }

/* =========================================================
   Dialer keypad
   ========================================================= */
.dialer-input-wrap {
    position: relative;
}

.dialer-input {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
    padding-right: 3rem;
    font-variant-numeric: tabular-nums;
}

.dialer-clear {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.dialer-clear:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

.dialer-clear:active { transform: translateY(-50%) scale(0.94); }

.dialer-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.keypad-key {
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
}

.keypad-key:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.keypad-key:active {
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: translateY(0);
}

.keypad-key .key-num {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.keypad-key .key-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
    min-height: 0.85em;
}

/* =========================================================
   API Manual page
   ========================================================= */
.api-toc {
    padding: 1rem !important;
}

.api-toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.api-toc-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}

.api-toc-item:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
    border-color: var(--border-light);
}

.api-toc-item i { color: var(--primary); }

.api-section {
    margin-bottom: 1.25rem;
    scroll-margin-top: 1rem;
}

.api-section h3 {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.65rem;
    margin-bottom: 0.85rem;
}

.api-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.api-list li {
    padding: 0.4rem 0 0.4rem 1.1rem;
    position: relative;
    color: var(--text-main);
    font-size: 0.875rem;
}

.api-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}

.api-endpoint {
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    margin-bottom: 0.85rem;
}

.api-endpoint:last-child { margin-bottom: 0; }

.api-endpoint p {
    font-size: 0.875rem;
    line-height: 1.55;
    margin: 0;
}

.api-endpoint-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.api-path {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-xs);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-all;
}

.http-method {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.5rem;
    border-radius: var(--radius-xs);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    border: 1px solid transparent;
    text-transform: uppercase;
}

.method-get    { background: var(--info-soft);    color: var(--info);    border-color: rgba(59,130,246,0.3); }
.method-post   { background: var(--success-soft); color: var(--success); border-color: rgba(16,185,129,0.3); }
.method-put    { background: var(--warning-soft); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.method-delete { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(239,68,68,0.3); }
.method-patch  { background: var(--primary-soft); color: var(--primary-light); border-color: rgba(99,102,241,0.3); }

.api-block {
    margin-top: 0.7rem;
}

.api-block-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.api-endpoint pre {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    overflow-x: auto;
    margin: 0;
}

.api-endpoint pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-main);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.55;
    white-space: pre;
    display: block;
}
