/* DashUI - Unified Design System for Divali SAS */
/* Variables now come from design-tokens.css */

/* Legacy aliases for backward compatibility */
:root {
    --primary: var(--color-primary);
    --primary-dark: var(--color-primary-hover);
    --secondary: var(--text-secondary);
    --success: var(--color-success);
    --warning: var(--color-warning);
    --danger: var(--color-error);
    --info: var(--color-info);
    --text-main: var(--text-primary);
    --radius: var(--radius-lg);
    --shadow: var(--shadow-md);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Component */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 1000;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2.5rem;
    text-decoration: none;
    color: white;
}

.sidebar-brand img {
    height: 45px;
}

.nav-group {
    margin-bottom: 1.5rem;
}

.nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    display: block;
    padding-left: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.nav-item i {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* Main Content Area */
.main-area {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.content-padding {
    padding: 2rem;
}

/* Grid Layouts */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

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

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-body {
    padding: 2rem;
}

.btn-close {
    background: #f1f5f9;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
}

/* Tables, Forms, etc. */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.table-container {
    overflow-x: auto;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
}

.dash-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    color: var(--secondary);
    font-size: 0.8rem;
    border-bottom: 2px solid var(--border);
}

.dash-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-inactive {
    background: #f1f5f9;
    color: #64748b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.input-field {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

.btn-ui {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

/* Responsive Overrides */
@media (max-width: 1024px) {
    .dash-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none; /* Hide sidebar on mobile */
    }

    .main-area {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .top-bar, .top-nav {
        flex-direction: column;
        align-items: flex-start;
        height: auto !important;
        padding: 1rem !important;
        gap: 1rem;
    }

    .top-nav div {
        width: 100%;
        justify-content: space-between;
    }

    .module-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .module-header > div {
        width: 100%;
    }

    .search-container-full {
        width: 100% !important;
    }

    .stats-grid {
        grid-template-columns: 1fr; /* Stack stats cards */
        gap: 1rem;
    }

    .card-custom {
        padding: 1.5rem !important;
    }

    .modal-content {
        width: 95% !important;
        margin: 1rem auto;
        padding: 0 !important;
    }

    .modal-body {
        padding: 1.5rem !important;
    }

    /* Form Grids to Stack */
    form .grid-template-columns,
    .modal-body .grid-template-columns,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .dash-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Ensure table container scrolls */
    .table-container,
    div[style*="overflow-x: auto"] {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Adjust buttons for touch */
    .btn-ui {
        width: 100%;
        justify-content: center;
        padding: 12px 20px; /* Larger tap target */
    }

    /* Adjust input fields for touch */
    .input-field {
        height: 48px; /* Larger tap target */
    }

    /* Adjust fonts */
    h1 {
        font-size: 1.8rem !important;
    }

    .container-fluid {
        padding: 1rem !important;
    }
}
