/* Koweng Collecteur - Design refondu */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 260px;
    --header-height: 64px;
    --primary: #059669;
    --primary-hover: #047857;
    --primary-light: #d1fae5;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --content-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
}

* {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* Responsive global : éviter débordement horizontal */
html {
    overflow-x: hidden;
}
body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ========== Layout principal (sidebar + contenu) ========== */
.app-layout {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    background: var(--content-bg);
    width: 100%;
    max-width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #047857 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
}

.sidebar-brand-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--sidebar-text-active);
    letter-spacing: -0.02em;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: rgba(148, 163, 184, 0.12);
    color: var(--sidebar-text-active);
}

.sidebar-nav a.active {
    background: rgba(5, 150, 105, 0.2);
    color: #34d399;
}

.sidebar-nav a.active:hover {
    background: rgba(5, 150, 105, 0.3);
    color: #6ee7b7;
}

.sidebar-nav a svg,
.sidebar-nav a i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sidebar-footer a:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 30;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-overlay.is-open {
    display: block;
    opacity: 1;
}

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 85vw);
        max-width: 280px;
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.3);
    }
    .sidebar-brand {
        padding: 1rem 1rem;
    }
    .sidebar-brand-text {
        font-size: 1rem;
    }
    .sidebar-nav a,
    .sidebar-footer a {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
}

@media (min-width: 1024px) {
    .sidebar-overlay { display: none !important; }
}

/* Zone contenu */
.app-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (max-width: 1023px) {
    .app-content { margin-left: 0; }
}

/* Barre du haut (mobile: menu + titre) */
.app-topbar {
    height: var(--header-height);
    min-height: 56px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
}
@media (min-width: 640px) {
    .app-topbar { padding: 0 1.25rem; }
}

.app-topbar .menu-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.app-topbar .menu-toggle:hover {
    background: var(--content-bg);
}

@media (min-width: 1024px) {
    .app-topbar .menu-toggle { display: none; }
}

.app-topbar .page-title-top {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}
@media (min-width: 640px) {
    .app-topbar .page-title-top { font-size: 1.125rem; max-width: none; }
}

@media (min-width: 1024px) {
    .app-topbar .page-title-top { display: none; }
}

/* Main */
.app-main {
    flex: 1;
    padding: 1rem 0.75rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .app-main { padding: 1.5rem 1rem; }
}

@media (min-width: 1024px) {
    .app-main { padding: 2rem 1.5rem; max-width: 1400px; margin: 0 auto; }
}

@media (min-width: 1280px) {
    .app-main { padding: 2rem 2.5rem; }
}

/* ========== Composants ========== */

/* En-tête de page */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .page-header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
        margin-bottom: 2rem;
    }
}

.page-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.2;
    word-break: break-word;
}

@media (min-width: 640px) {
    .page-title { font-size: 1.5rem; }
}

@media (min-width: 1024px) {
    .page-title { font-size: 1.875rem; }
}

.page-subtitle {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Cartes */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.card-elevated {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--card-bg);
}

@media (min-width: 640px) {
    .card-header { padding: 1.25rem 1.25rem; gap: 1rem; }
}

@media (min-width: 1024px) {
    .card-header { padding: 1.25rem 1.5rem; }
}

.card-header h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
}

.card-body {
    padding: 1rem;
}

@media (min-width: 640px) {
    .card-body { padding: 1.25rem; }
}

@media (min-width: 1024px) {
    .card-body { padding: 1.5rem; }
}

/* Stats (dashboard) */
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    min-width: 0;
}

.stat-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .stat-card { padding: 1.25rem; gap: 1rem; border-radius: 16px; }
    .stat-card .stat-icon { width: 52px; height: 52px; }
}

@media (min-width: 1024px) {
    .stat-card { padding: 1.5rem; }
    .stat-card .stat-icon { width: 56px; height: 56px; border-radius: 14px; }
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    min-height: 44px;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .btn { padding: 0.75rem 1.25rem; font-size: 0.9375rem; border-radius: 12px; }
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.25);
}

.btn-primary {
    background: linear-gradient(180deg, #059669 0%, #047857 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #047857 0%, #065f46 100%);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: var(--content-bg);
    border-color: #cbd5e1;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--content-bg);
    color: var(--text);
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 8px;
    min-height: 36px;
}

@media (min-width: 640px) {
    .btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.9375rem;
    background: transparent;
    border: none;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* Formulaires */
.input-field {
    width: 100%;
    max-width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    font-size: 16px;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .input-field { padding: 0.75rem 1rem; font-size: 0.9375rem; border-radius: 12px; }
}

.input-field::placeholder {
    color: #94a3b8;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.label-field {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* Tableaux */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    max-width: 100%;
}

.table-modern {
    width: 100%;
    min-width: 400px;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table-modern th {
    padding: 0.75rem 0.875rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.table-modern th:last-child {
    border-right: none;
}

.table-modern td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid #f1f5f9;
    color: var(--text);
}

@media (min-width: 640px) {
    .table-modern { font-size: 0.875rem; }
    .table-modern th { padding: 0.875rem 1rem; font-size: 0.7rem; }
    .table-modern td { padding: 0.875rem 1rem; }
}

@media (min-width: 1024px) {
    .table-modern { font-size: 0.9375rem; min-width: 500px; }
    .table-modern th { padding: 1rem 1.25rem; font-size: 0.75rem; }
    .table-modern td { padding: 1rem 1.25rem; }
}

.table-modern td:last-child {
    border-right: none;
}

.table-modern tbody tr {
    background: var(--card-bg);
    transition: background 0.1s ease;
}

.table-modern tbody tr:nth-child(even) {
    background: #fafafa;
}

.table-modern tbody tr:hover {
    background: var(--primary-light);
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-modern tbody tr td[colspan] {
    padding: 2rem 0.875rem;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    border-right: none;
}

@media (min-width: 640px) {
    .table-modern tbody tr td[colspan] { padding: 2.5rem 1rem; }
}

@media (min-width: 1024px) {
    .table-modern tbody tr td[colspan] { padding: 3rem 1.25rem; }
}

/* Alertes */
.alert-success {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: #ecfdf5;
    color: #065f46;
    border: 1.5px solid #a7f3d0;
    font-weight: 500;
    font-size: 0.875rem;
}

.alert-error {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
    border: 1.5px solid #fecaca;
    font-weight: 500;
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .alert-success, .alert-error {
        padding: 1rem 1.25rem;
        font-size: 0.9375rem;
        border-radius: 12px;
    }
}

/* Lien style bouton */
.link-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.15s ease;
}

.link-button:hover {
    background: var(--primary-light);
}

/* ========== Modal reçu (impression) ========== */
.print-receipt-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.print-receipt-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.print-receipt-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    cursor: pointer;
}

.print-receipt-modal-box {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.print-receipt-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: background 0.15s ease, color 0.15s ease;
}

.print-receipt-modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.print-receipt-iframe {
    width: 100%;
    height: 85vh;
    min-height: 400px;
    border: none;
    display: block;
}
