/* ============================================
   ETAKA TRADLINK — MODERN DESIGN SYSTEM
   ============================================ */

/* CSS Custom Properties (Design Tokens) */
:root {
    /* Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Backgrounds */
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-xs: 6px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* ============================================
   GLOBAL RESETS & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ============================================
   PAGE LOADER
   ============================================ */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#page-loader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   SIDEBAR
   ============================================ */
.section-menu-left {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
}

.section-menu-left::-webkit-scrollbar {
    width: 4px;
}

.section-menu-left::-webkit-scrollbar-track {
    background: transparent;
}

.section-menu-left::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.section-menu-left .box-logo {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-menu-left .box-logo img {
    max-height: 36px;
    width: auto;
}

.section-menu-left .center {
    padding: 12px 10px;
}

.section-menu-left .center-itemm {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    margin-bottom: 1px;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    font-size: 13.5px;
    font-weight: 500;
    gap: 10px;
}

.menu-item a .icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.menu-item a .text {
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 500;
}

.menu-item a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.menu-item.active a {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

.sidebarbuttonset a {
    background: transparent !important;
}

/* ============================================
   HEADER
   ============================================ */
.header-dashboard {
    background: var(--bg-surface) !important;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.header-dashboard .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.wallet-badge {
    background: var(--success);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wallet-badge i {
    font-size: 0.8rem;
}

.header-grid {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.header-user h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-user h5 {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* User dropdown */
.custom-dropdown {
    position: relative;
}

.custom-dropdown-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.custom-dropdown-toggle:hover {
    background: var(--bg-surface-hover);
    border-color: var(--primary-light);
}

.custom-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 160px;
    z-index: 1000;
    list-style: none;
}

.custom-dropdown-menu.show {
    display: block;
}

.custom-dropdown-menu li {
    padding: 0;
}

.custom-dropdown-menu li .user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--border-radius-xs);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background var(--transition-fast);
    width: 100%;
}

.custom-dropdown-menu li .user-item:hover {
    background: var(--bg-surface-hover);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-primary);
}

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

.main-content {
    padding: 0;
}

.main-content-inner {
    padding: 24px;
}

/* ============================================
   CARDS & STAT CARDS
   ============================================ */
.stat-card {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* ============================================
   TABLES & DATATABLES
   ============================================ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 12px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: var(--bg-surface-hover);
}

/* DataTables overrides */
div.dataTables_wrapper {
    font-family: 'Inter', sans-serif;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    padding: 6px 10px;
    font-size: 0.85rem;
    transition: border-color var(--transition-fast);
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-xs) !important;
    margin: 0 2px;
    padding: 4px 10px !important;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
    color: #fff !important;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--border-radius-xs);
    padding: 8px 16px;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 3px 7px;
    font-size: 0.75rem;
    border-radius: 4px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

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

.btn-success:hover {
    background: #059669;
    border-color: #059669;
}

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

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

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

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-outline-secondary {
    background: transparent;
    color: var(--secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--secondary);
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    outline: none;
}

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

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

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

/* Validation states */
.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--success);
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--danger);
}

.invalid-feedback {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.bg-success {
    background: var(--success-light) !important;
    color: #065f46 !important;
}

.badge.bg-danger {
    background: var(--danger-light) !important;
    color: #991b1b !important;
}

.badge.bg-warning {
    background: var(--warning-light) !important;
    color: #92400e !important;
}

.badge.bg-info {
    background: var(--info-light) !important;
    color: #1e40af !important;
}

.badge.bg-secondary {
    background: #f1f5f9 !important;
    color: var(--text-secondary) !important;
}

/* ============================================
   ALERTS / TOASTS
   ============================================ */
.alert {
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
}

/* Toast overrides */
#toast-container .toast {
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
}

/* ============================================
   WYGWYS Box (Content Cards)
   ============================================ */
.wg-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

/* ============================================
   FOOTER
   ============================================ */
.bottom-page {
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary) !important;
    padding: 14px 24px !important;
    text-align: center;
    font-size: 0.8rem;
}

.bottom-page .body-text {
    color: var(--text-secondary);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

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

    .section-menu-left.show {
        transform: translateX(0);
    }

    .section-content-right {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    /* Mobile overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }

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

    .main-content-inner {
        padding: 16px;
    }

    .stat-card {
        margin-bottom: 0;
    }
}

@media (max-width: 575.98px) {
    .main-content-inner {
        padding: 12px;
    }

    .header-dashboard .wrap {
        padding: 0;
    }

    .wallet-badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */
.table-loading {
    position: relative;
    min-height: 100px;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

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

.empty-state p {
    font-size: 0.9rem;
}

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

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .section-menu-left,
    .header-dashboard,
    .bottom-page,
    .sidebar-toggle {
        display: none !important;
    }

    .section-content-right {
        margin-left: 0 !important;
    }
}
