/* Ma Passion Bois - Gestion
   Palette : vert forêt, beige, crème, bois
*/

:root {
    --forest: #2d5a3d;
    --forest-dark: #1e3d2a;
    --forest-light: #3d7a52;
    --cream: #f7f3eb;
    --beige: #e8dfd0;
    --wood: #c4a574;
    --wood-dark: #8b6914;
    --text: #2c2c2c;
    --text-muted: #6b6b6b;
    --white: #ffffff;
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #e67e22;
    --info: #2980b9;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(45, 90, 61, 0.08);
    --shadow-hover: 0 4px 20px rgba(45, 90, 61, 0.12);
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Source Sans 3', 'Nunito', system-ui, sans-serif;
    background: var(--cream);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--forest-dark) 0%, var(--forest) 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    transition: all 0.15s;
    font-weight: 500;
}

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

.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: white;
    font-weight: 600;
}

.nav-icon {
    font-size: 1.15rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.btn-logout {
    display: inline-block;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.25);
    transition: all 0.15s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--forest);
    border-radius: 1px;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--forest-dark);
    font-family: 'Nunito', sans-serif;
}

.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
}

.footer {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--forest-dark);
    font-family: 'Nunito', sans-serif;
}

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

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 3px solid var(--forest);
}

.stat-card.warning { border-top-color: var(--warning); }
.stat-card.info { border-top-color: var(--info); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.muted { border-top-color: #95a5a6; }

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--forest-dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--beige);
}

th {
    background: var(--beige);
    font-weight: 600;
    color: var(--forest-dark);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:hover td {
    background: rgba(45, 90, 61, 0.03);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-warning { background: #fef3e2; color: #b35900; }
.badge-info { background: #e8f4fc; color: #1a6a9a; }
.badge-success { background: #e6f7ed; color: #1e7a45; }
.badge-muted { background: #f0f0f0; color: #666; }
.badge-danger { background: #fdecea; color: #a93226; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}

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

.btn-secondary {
    background: var(--beige);
    color: var(--forest-dark);
}
.btn-secondary:hover {
    background: #d9ceba;
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #219a52; }

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

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--forest);
    color: var(--forest);
}
.btn-outline:hover {
    background: var(--forest);
    color: white;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--forest-dark);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid #d4c9b8;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--forest);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* Alerts */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.alert-success { background: #e6f7ed; color: #1e7a45; border: 1px solid #b8e6c9; }
.alert-error, .alert-danger { background: #fdecea; color: #a93226; border: 1px solid #f5c6c2; }
.alert-warning { background: #fef3e2; color: #b35900; border: 1px solid #f5d9a8; }
.alert-info { background: #e8f4fc; color: #1a6a9a; border: 1px solid #b8d9ef; }

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cream) 0%, var(--beige) 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(45, 90, 61, 0.12);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card .logo {
    justify-content: center;
    margin-bottom: 0.5rem;
    color: var(--forest-dark);
    font-size: 1.3rem;
}

.login-card h1 {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-weight: 500;
}

/* Filters / search */
.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: flex-end;
}

.filters .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

/* Stock indicators */
.stock-ok { color: var(--success); font-weight: 600; }
.stock-low { color: var(--warning); font-weight: 600; }
.stock-out { color: var(--danger); font-weight: 600; }

/* Modal simple */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--forest-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close {
        display: block;
    }
    .main-wrapper {
        margin-left: 0;
    }
    .menu-toggle {
        display: flex;
    }
    .content {
        padding: 1rem;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    th, td {
        padding: 0.55rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-100 { width: 100%; }

/* Order lines editor */
.lignes-table input {
    width: 80px;
    padding: 0.4rem;
}

.lignes-table .prix {
    width: 90px;
}

.total-box {
    background: var(--beige);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--forest-dark);
    margin-top: 1rem;
}

.reste-a-payer {
    color: var(--warning);
}