/* ============================================
   IVR System - Custom Styles
   Modern dark theme with glassmorphism
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 65px;
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --accent: #0ea5e9;
    --accent-light: #38bdf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255, 255, 255, 0.9);
    --bg-input: #ffffff;
    --border-color: rgba(99, 102, 241, 0.15);
    --border-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --bs-table-bg: #fff !important;
}

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

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

/* Background gradient pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: var(--transition);
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table> :not(caption)>*>* {
    background-color: var(--bs-table-bg);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.brand-text h5 {
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-text small {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    margin-bottom: 4px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.sidebar-nav .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: var(--transition);
}

.sidebar-nav .nav-link:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.08));
    box-shadow: var(--shadow-glow);
}

.sidebar-nav .nav-link.active::before {
    opacity: 1;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

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

.user-avatar i {
    font-size: 2rem;
    color: var(--primary-light);
}

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

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #f8fafc;
}

.user-role {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ============ TOPBAR ============ */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 1030;
}

.sidebar-toggle {
    color: var(--text-secondary);
    font-size: 1.4rem;
    padding: 4px;
    display: none;
}

.topbar-title h4 {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============ CONTENT WRAPPER ============ */
.content-wrapper {
    padding: 24px;
}

/* ============ GLASS CARDS ============ */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.glass-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.card-glass {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* ============ STAT CARDS ============ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.stat-icon.purple {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.stat-icon.cyan {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============ TABLES ============ */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-container .table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h5 {
    font-weight: 700;
    margin: 0;
    font-size: 1rem;
}

.table {
    margin-bottom: 0;
    color: var(--text-primary);
}

.table thead th {
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 14px 16px;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.table thead th:hover {
    color: var(--primary-light);
}

.table thead th.sort-active {
    color: var(--primary-light);
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.88rem;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

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

.table-pagination {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pagination .page-link {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    transition: var(--transition);
}

.pagination .page-link:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    opacity: 0.4;
}

/* ============ CHARTS ============ */
.chart-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.chart-container:hover {
    border-color: var(--border-glow);
}

.chart-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart-wrapper {
    position: relative;
    height: 280px;
}

/* ============ FORMS ============ */
.form-control,
.form-select {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Checkbox visibility fix */
.form-check-input {
    background-color: var(--bg-input);
    border: 1.5px solid #cbd5e1;
    /* Visible gray border */
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-group-text {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--primary-light);
    border-radius: var(--radius-sm);
}

/* ============ BUTTONS ============ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary-light);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-outline-primary:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-light);
    color: #fff;
}

.btn-outline-danger {
    border-color: rgba(239, 68, 68, 0.5);
    color: var(--danger);
    border-radius: var(--radius-sm);
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    border: none;
    font-weight: 600;
}

/* ============ BADGES ============ */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 6px;
}

/* ============ FILTER PANEL ============ */
.filter-panel {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.filter-panel .filter-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ LOGIN PAGE ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 40px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% 100%;
    animation: shimmer 3s ease infinite;
}

@keyframes shimmer {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon-container {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.login-logo h3 {
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============ SETTINGS PAGE ============ */
.settings-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-card .card-header-custom {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-card .card-header-custom h5 {
    font-weight: 700;
    margin: 0;
}

.settings-card .card-body-custom {
    padding: 24px;
}

.webhook-url-display {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    word-break: break-all;
}

/* ============ MOVING DOTS LOADER ============ */
.dots-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
    backdrop-filter: blur(2px);
    gap: 6px;
}

.dots-loader .dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: bounceDots 1.4s infinite ease-in-out both;
}

.dots-loader .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-loader .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounceDots {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ============ MODAL COMPONENTS ============ */
.modal-content {
    background: var(--bg-card);
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
}

.modal-header {
    border-bottom: 1px solid var(--glass-border);
}

.modal-footer {
    border-top: 1px solid var(--glass-border);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============ ACTION BUTTONS ============ */
.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.action-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.15s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(5) {
    animation-delay: 0.25s;
}

.stat-card:nth-child(6) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(7) {
    animation-delay: 0.35s;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block !important;
    }

    .content-wrapper {
        padding: 16px;
    }
}

@media (max-width: 767.98px) {
    .stat-value {
        font-size: 1.4rem;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch !important;
    }

    .topbar-actions .badge {
        display: none;
    }
}

/* ============ OVERLAY FOR MOBILE SIDEBAR ============ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    display: none;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.show {
    display: block;
}

/* ============ TOAST NOTIFICATION ============ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.custom-toast {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    min-width: 280px;
    box-shadow: var(--shadow-lg);
}

/* ============ CALL DETAIL MODAL ============ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.modal-header {
    border-bottom: 1px solid var(--glass-border);
    padding: 20px 24px;
}

.modal-header .modal-title {
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--glass-border);
    padding: 16px 24px;
}

.detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--glass-border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    width: 140px;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.detail-value {
    color: var(--text-primary);
    font-size: 0.9rem;
}