:root {
    --bg-color: #0d0f1a;
    --sidebar-bg: rgba(20, 23, 40, 0.4);
    --panel-bg: rgba(25, 29, 48, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary-color: #6c5ce7;
    --primary-hover: #5b4bc4;
    --text-main: #f1f2f6;
    --text-muted: #a4b0be;
    --danger: #ff4757;
    --success: #2ed573;

    --purple: #9b59b6;
    --blue: #3498db;
    --orange: #e67e22;
    --green: #2ecc71;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(108, 92, 231, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(52, 152, 219, 0.1), transparent 25%);
    background-size: cover;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    /* App feel */
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--panel-border);
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-color), #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.logo-area h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-area span {
    font-weight: 300;
    color: var(--primary-color);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(108, 92, 231, 0.2), transparent);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--panel-border);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    margin-top: 4px;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.btn-danger {
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    padding: 6px 12px;
    font-size: 0.9rem;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.stat-card {
    padding: 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.purple {
    background: rgba(155, 89, 182, 0.2);
    color: #c0392b;
    color: var(--purple);
}

.stat-icon.blue {
    background: rgba(52, 152, 219, 0.2);
    color: var(--blue);
}

.stat-icon.orange {
    background: rgba(230, 126, 34, 0.2);
    color: var(--orange);
}

.stat-icon.green {
    background: rgba(46, 204, 113, 0.2);
    color: var(--green);
}

.stat-details p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-details h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Table Area */
.table-container {
    padding: 24px;
    border-radius: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 8px 16px;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.table-search {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 12px;
    width: 300px;
}

.table-search i {
    color: var(--text-muted);
    margin-right: 8px;
}

.table-search input {
    background: none;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
    font-family: inherit;
}

.table-responsive {
    overflow-x: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--panel-border);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.95rem;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    padding: 24px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
}

/* Fix generic select arrow visibility in dark mode */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a4b0be%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat, repeat;
    background-position: right .7em top 50%, 0 0;
    background-size: .65em auto, 100%;
}

select option {
    background: var(--panel-bg);
    color: white;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    min-width: 250px;
    padding: 16px;
    border-radius: 8px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease forwards;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

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

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* =========================================
   Mobile Responsiveness
   ========================================= */
@media (max-width: 768px) {
    /* Main Layout */
    .app-container {
        flex-direction: column;
    }
    
    /* Sidebar turns into top nav */
    .sidebar {
        width: 100%;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        flex-direction: column;
    }
    
    .logo-area {
        margin-bottom: 16px;
        justify-content: center;
    }
    
    .nav-menu {
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
    }
    
    .nav-item {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .user-info {
        padding-top: 12px;
        justify-content: space-between;
    }
    
    /* Main Content */
    .main-content {
        padding: 16px;
        gap: 16px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn {
        width: 100%;
        justify-content: center; /* Center icon and text */
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Table Enhancements */
    .table-container {
        padding: 16px;
    }
    
    .table-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .table-header > div:first-child {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        text-align: center;
    }
    
    .table-search {
        width: 100%;
    }
    
    /* Modal Adapts */
    .modal-content {
        max-width: 90%;
        padding: 20px;
        max-height: 90vh; /* Don't spill off screen */
        overflow-y: auto;
    }
    
    .form-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .modal-footer {
        flex-direction: column-reverse; /* Cancel on bottom on mobile */
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Table Mobile Card Layout */
    .data-table thead {
        display: none; /* Hide table headers */
    }

    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: 16px;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid var(--panel-border);
        border-radius: 12px;
        padding: 12px;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        text-align: right;
    }

    .data-table td:last-child {
        border-bottom: none;
        justify-content: flex-end; /* Align actions to the right */
        gap: 10px;
        padding-top: 12px;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
        margin-right: 15px;
    }
}