/* theme.css — Modern SaaS Glassmorphism Design System */
/* Inspired by Linear, Vercel Dashboard, Stripe Dashboard */

/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ===== Design Tokens ===== */
:root {
    --et-primary: #5C6BC0;
    --et-primary-dark: #3949AB;
    --et-primary-darker: #1A237E;
    --et-primary-light: #E8EAF6;
    --et-surface: #FFFFFF;
    --et-background: #F0F2F5;
    --et-text-primary: #1A1A2E;
    --et-text-secondary: #6C757D;
    --et-success: #43A047;
    --et-warning: #FB8C00;
    --et-danger: #E53935;
    --et-info: #1E88E5;

    --et-shadow-1: 0 4px 24px rgba(92, 107, 192, 0.08);
    --et-shadow-2: 0 8px 32px rgba(92, 107, 192, 0.12);
    --et-shadow-3: 0 12px 48px rgba(92, 107, 192, 0.18);

    --et-radius-card: 16px;
    --et-radius-btn: 10px;
    --et-radius-pill: 20px;

    --et-sidebar-width: 250px;
    --et-sidebar-collapsed: 70px;
    --et-topbar-height: 60px;
}

/* ===== Base ===== */
body.et-layout {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--et-text-primary);
    background-color: var(--et-background);
    margin: 0;
    padding: 0;
    position: relative;
}

/* ===== Body Mesh Gradient Background ===== */
body.et-layout::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(92, 107, 192, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(118, 75, 162, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(79, 172, 254, 0.05) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ===== BS5 Overrides ===== */
.btn-primary {
    background-color: var(--et-primary);
    border-color: var(--et-primary);
    border-radius: var(--et-radius-btn);
    transition: all 0.2s ease;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--et-primary-dark);
    border-color: var(--et-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(92, 107, 192, 0.3);
}
.btn-outline-primary {
    color: var(--et-primary);
    border-color: var(--et-primary);
    border-radius: var(--et-radius-btn);
    transition: all 0.2s ease;
}
.btn-outline-primary:hover {
    background-color: var(--et-primary);
    color: #fff;
    transform: translateY(-1px);
}
.btn {
    border-radius: var(--et-radius-btn);
    font-weight: 500;
    transition: all 0.2s ease;
}

.card {
    border: none;
    border-radius: var(--et-radius-card);
    box-shadow: var(--et-shadow-1);
}
.card-hover {
    transition: all 0.2s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--et-shadow-2);
}

.badge { border-radius: var(--et-radius-pill); font-weight: 500; }

.form-control, .form-select {
    border-radius: var(--et-radius-btn);
    border-color: #dee2e6;
    font-size: 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--et-primary);
    box-shadow: 0 0 0 0.2rem rgba(92, 107, 192, 0.25);
}

.nav-pills .nav-link.active {
    background-color: var(--et-primary);
    border-radius: var(--et-radius-pill);
}
.nav-pills .nav-link {
    border-radius: var(--et-radius-pill);
    color: var(--et-text-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link {
    transition: all 0.2s ease;
}
.nav-tabs .nav-link.active {
    color: var(--et-primary);
    border-bottom: 2px solid var(--et-primary);
    font-weight: 600;
}

/* ===== Sidebar (Glassmorphic) ===== */
.et-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--et-sidebar-width);
    height: 100vh;
    background: rgba(26, 35, 126, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.et-sidebar.collapsed {
    width: var(--et-sidebar-collapsed);
}

.et-sidebar-brand {
    height: var(--et-topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.et-sidebar-brand img {
    height: 32px;
    width: auto;
}
.et-sidebar-brand .brand-text {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    margin-left: 12px;
    white-space: nowrap;
    opacity: 1;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
}
.et-sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.et-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}
.et-sidebar-nav .nav-item {
    margin-bottom: 2px;
}
.et-sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    border-left: 3px solid transparent;
}
.et-sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.et-sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #fff;
}
.et-sidebar-nav .nav-link i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.et-sidebar-nav .nav-link .menu-text {
    margin-left: 12px;
    opacity: 1;
    transition: opacity 0.2s ease;
}
.et-sidebar.collapsed .nav-link .menu-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
/* Tooltip on collapsed sidebar hover */
.et-sidebar.collapsed .nav-link {
    position: relative;
}
.et-sidebar.collapsed .nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--et-sidebar-collapsed) - 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--et-text-primary);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1040;
}
.et-sidebar.collapsed .nav-link:hover::after {
    opacity: 1;
}

.et-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.et-sidebar-footer .user-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.4;
}
.et-sidebar-footer .user-name {
    font-weight: 600;
    color: #fff;
    display: block;
}
.et-sidebar-footer .user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    display: block;
}

.et-sidebar-toggle {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s ease;
    position: static;
}
.et-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.et-sidebar-toggle i {
    font-size: 18px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}
.et-sidebar-toggle .toggle-text {
    opacity: 1;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}
.et-sidebar.collapsed .et-sidebar-toggle i {
    transform: rotate(180deg);
}
.et-sidebar.collapsed .et-sidebar-toggle .toggle-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
/* Collapsed sidebar: center the toggle icon */
.et-sidebar.collapsed .et-sidebar-toggle {
    justify-content: center;
    padding: 12px 0;
}

/* ===== Topbar (Glassmorphic) ===== */
.et-topbar {
    position: sticky;
    top: 0;
    height: var(--et-topbar-height);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    margin-left: var(--et-sidebar-width);
    z-index: 1020;
    transition: margin-left 0.3s ease;
}
/* Collapsed state uses body class — works regardless of DOM order */
body.sidebar-collapsed .et-topbar {
    margin-left: var(--et-sidebar-collapsed);
}

.et-topbar .breadcrumb {
    margin: 0;
    background: none;
    padding: 0;
    font-size: 14px;
}

/* ===== Main Content ===== */
.et-content {
    margin-left: var(--et-sidebar-width);
    padding: 24px;
    min-height: calc(100vh - var(--et-topbar-height));
    transition: margin-left 0.3s ease;
}
body.sidebar-collapsed .et-content {
    margin-left: var(--et-sidebar-collapsed);
}

/* ===== Stat Cards (Gradient) ===== */
.et-stat-card {
    border-radius: var(--et-radius-card);
    padding: 24px;
    display: block;
    position: relative;
    overflow: hidden;
    min-height: 140px;
    transition: all 0.2s ease;
    box-shadow: var(--et-shadow-1);
    cursor: default;
}
.et-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}
.et-stat-card .stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}
.et-stat-card .stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    margin-top: 8px;
}
.et-stat-card .stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.et-stat-card .stat-change {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 12px;
}

/* Gradient modifier classes */
.et-stat-card.gradient-purple {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.et-stat-card.gradient-green {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
.et-stat-card.gradient-blue {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.et-stat-card.gradient-pink {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* Legacy accent classes — kept for backward compat */
.et-stat-card.accent-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.et-stat-card.accent-success { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.et-stat-card.accent-info    { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.et-stat-card.accent-warning { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }

/* Utility bg colours */
.bg-et-primary { background-color: var(--et-primary); }
.bg-et-success { background-color: var(--et-success); }
.bg-et-info    { background-color: var(--et-info); }
.bg-et-warning { background-color: var(--et-warning); }
.bg-et-danger  { background-color: var(--et-danger); }

/* ===== Welcome Banner ===== */
.et-welcome-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: var(--et-radius-card);
    padding: 28px 32px;
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}
.et-welcome-banner h4,
.et-welcome-banner h5,
.et-welcome-banner p {
    color: #fff;
    position: relative;
    z-index: 1;
}
.et-welcome-banner::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}
.et-welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -60px;
    right: 60px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

/* ===== Quick Actions ===== */
.et-quick-action {
    background: var(--et-surface);
    border-radius: var(--et-radius-card);
    box-shadow: var(--et-shadow-1);
    border: 1px solid rgba(92, 107, 192, 0.1);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--et-text-primary);
}
.et-quick-action:hover {
    transform: translateY(-3px);
    box-shadow: var(--et-shadow-2);
    border-color: rgba(92, 107, 192, 0.2);
    color: var(--et-text-primary);
    text-decoration: none;
}
.et-quick-action .action-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.et-quick-action .action-label {
    font-weight: 600;
    font-size: 14px;
}
.et-quick-action .action-desc {
    font-size: 12px;
    color: var(--et-text-secondary);
    margin-top: 2px;
}

/* ===== Chart Container ===== */
.et-chart-card {
    background: var(--et-surface);
    border-radius: var(--et-radius-card);
    box-shadow: var(--et-shadow-1);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.et-chart-card .chart-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 16px;
    align-self: flex-start;
    color: var(--et-text-primary);
}

/* ===== Animated Counter ===== */
.et-counter {
    font-family: 'JetBrains Mono', monospace;
}

/* ===== Wizard ===== */
.et-wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
}
.et-wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--et-text-secondary);
    font-weight: 500;
}
.et-wizard-step .step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #E0E0E0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease;
}
.et-wizard-step.active .step-circle {
    background: var(--et-primary);
}
.et-wizard-step.completed .step-circle {
    background: var(--et-success);
}
.et-wizard-step .step-label {
    white-space: nowrap;
}
.et-wizard-connector {
    width: 60px;
    height: 2px;
    background: #E0E0E0;
    margin: 0 4px;
    transition: background 0.2s ease;
}
.et-wizard-connector.completed {
    background: var(--et-success);
}
.et-wizard-panel {
    display: none;
}
.et-wizard-panel.active {
    display: block;
}

/* ===== Modern Table Styles ===== */
.et-content .table {
    font-size: 13.5px;
    color: var(--et-text-primary);
}
.et-content .table thead th {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--et-text-secondary);
    border-bottom: 2px solid #E8EAF6;
    padding: 12px 16px;
    white-space: nowrap;
    background: #FAFBFD;
}
.et-content .table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #F0F2F5;
    line-height: 1.5;
}
.et-content .table tbody tr {
    transition: background 0.15s ease;
}
.et-content .table tbody tr:hover {
    background: rgba(92, 107, 192, 0.04);
}
.et-content .table tbody tr:last-child td {
    border-bottom: none;
}
/* Compact table variant */
.et-content .table.table-compact thead th {
    padding: 10px 12px;
    font-size: 11px;
}
.et-content .table.table-compact tbody td {
    padding: 10px 12px;
    font-size: 13px;
}
/* Table action buttons */
.et-content .table .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}
/* Status dots in tables */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
}
.status-dot.dot-success { background: var(--et-success); }
.status-dot.dot-warning { background: var(--et-warning); }
.status-dot.dot-danger { background: var(--et-danger); }
.status-dot.dot-muted { background: #CBD5E1; }
/* DataTables overrides for modern look */
/* Fix: Bootstrap .row has -12px negative margins on both sides causing overflow inside
   table-responsive (overflow-x:auto). Zero them out so controls don't get clipped. */
.dataTables_wrapper > .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.dataTables_wrapper .dataTables_length {
    padding: 12px 4px 6px;
}
.dataTables_wrapper .dataTables_filter {
    padding: 12px 4px 6px;
}
.dataTables_wrapper .dataTables_info {
    font-size: 12.5px;
    color: var(--et-text-secondary);
    padding: 10px 4px 12px;
}
.dataTables_wrapper .dataTables_paginate {
    padding: 6px 4px 12px;
}
.dataTables_wrapper .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    font-size: 13px;
}
.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 0;
    font-size: 13px;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #dee2e6;
    border-radius: var(--et-radius-btn);
    padding: 6px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--et-primary);
    box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.1);
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 4px 28px 4px 8px;
    font-size: 13px;
    min-width: 60px;
}
.dataTables_wrapper .dataTables_paginate .page-link {
    border-radius: 6px !important;
    font-size: 13px;
    padding: 4px 10px;
    margin: 0 2px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: var(--et-text-primary);
    transition: all 0.15s ease;
    line-height: 1.5;
}
.dataTables_wrapper .dataTables_paginate .page-link:hover {
    background: var(--et-primary-light);
    border-color: var(--et-primary);
    color: var(--et-primary);
}
.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background: var(--et-primary);
    border-color: var(--et-primary);
    color: #fff;
}
.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    color: #adb5bd;
    background: #f8f9fa;
    border-color: #dee2e6;
}
.dataTables_wrapper .dataTables_paginate .pagination {
    margin-bottom: 0;
    flex-wrap: wrap;
    gap: 2px;
}
/* Badge refinements for tables */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    letter-spacing: 0.3px;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .et-sidebar {
        transform: translateX(-100%);
        width: var(--et-sidebar-width) !important;
        /* Disable backdrop-filter on mobile for performance */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(26, 35, 126, 0.97);
    }
    .et-sidebar.mobile-open {
        transform: translateX(0);
    }
    .et-sidebar-toggle { display: none; }
    .et-topbar, .et-content {
        margin-left: 0 !important;
    }
    .et-sidebar-backdrop {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1029;
        display: none;
    }
    .et-sidebar-backdrop.show { display: block; }
}

@media (max-width: 575.98px) {
    .et-stat-card { padding: 16px; min-height: 110px; }
    .et-stat-card .stat-value { font-size: 22px; }
    .et-stat-card .stat-icon { width: 36px; height: 36px; font-size: 20px; }
    .et-content { padding: 16px; }
    .et-wizard-step .step-label { display: none; }
    .et-wizard-connector { width: 24px; }
    .et-welcome-banner { padding: 20px; }
}

/* ===== Responsive Dropify ===== */
/* Fix icon/text overlap — line-height:22px < font-size:50px causes glyph to overflow line box */
.dropify-wrapper .dropify-message span.file-icon {
    display: block;
    line-height: 1;
}
@media (max-width: 767.98px) {
    .dropify-wrapper .dropify-message span.file-icon {
        font-size: 32px !important;
    }
    .dropify-wrapper .dropify-message p {
        font-size: 12px;
        line-height: 1.3;
        word-break: break-word;
    }
}
@media (max-width: 575.98px) {
    .dropify-wrapper .dropify-message span.file-icon {
        font-size: 24px !important;
    }
    .dropify-wrapper .dropify-message p {
        font-size: 10px;
        line-height: 1.3;
        word-break: break-word;
    }
}

/* ===== Loading Overlay ===== */
.et-loader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}
.et-loader.show { display: flex; }
