:root {
    --cosider-blue: #004a99;
    --cosider-deep-blue: #003366;
    --industrial-gray: #333333;
    --light-gray: #f4f7f6;
    --accent-orange: #f39c12;
    --white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 65px;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', 'Segoe UI', sans-serif;
}

body {
    background-color: var(--light-gray);
    color: var(--industrial-gray);
    min-height: 100vh;
}

/* Login Page Styles */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(rgba(0, 51, 102, 0.75), rgba(0, 51, 102, 0.75)), url('arrier.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100vh;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 420px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--cosider-deep-blue);
    color: var(--white);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header img {
    max-width: 120px;
    margin-bottom: 0.5rem;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left: 4px solid var(--accent-orange);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
}

header {
    height: var(--header-height);
    background: var(--white);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 999;
}

.container {
    padding: 2rem;
    max-width: 1300px;
    margin: 0 auto;
}

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-wide {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
}

/* Sections */
.form-section {
    display: none;
}

.form-section.active {
    display: block;
}

.card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-top: 4px solid var(--cosider-blue);
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stats-grid .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--cosider-deep-blue);
}

/* Forms */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input,
select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.btn-primary {
    background: var(--cosider-blue);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.btn-logout {
    color: #e74c3c;
    background: transparent;
    border: 1px solid #e74c3c;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* Tables */
.table-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    color: var(--cosider-deep-blue);
}

td {
    padding: 1rem;
    border-top: 1px solid #eee;
}

/* Role Visibility */
.admin-only,
.gestion-only,
.magasin-only {
    display: none !important;
}

body.role-admin .admin-only,
body.role-gestion .gestion-only,
body.role-magasin .magasin-only {
    display: block !important;
}

body.role-admin th.admin-only,
body.role-admin td.admin-only,
body.role-gestion th.gestion-only,
body.role-gestion td.gestion-only,
body.role-magasin th.magasin-only,
body.role-magasin td.magasin-only {
    display: table-cell !important;
}

body.role-admin .nav-link.admin-only,
body.role-gestion .nav-link.gestion-only,
body.role-magasin .nav-link.magasin-only {
    display: flex !important;
}

/* Mixed Visibility examples */
body.role-admin .gestion-only,
body.role-admin .magasin-only {
    display: block !important;
}

body.role-gestion .magasin-only {
    display: block !important;
}

/* Mobile */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    #mobile-toggle {
        display: block !important;
    }

    header {
        padding: 0 1rem;
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid .value {
        font-size: 1.5rem;
    }

    th,
    td {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Credit Text */
.credit-text {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
    font-style: italic;
}