/* ============================================================
   BRIORD ACTIONS - Design System
   Sobre, élégant, moderne — palette terreuse & verte
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=DM+Sans:wght@300;400;500;600&display=swap');

/* --- Variables --- */
:root {
    --c-bg:         #F5F3EF;
    --c-surface:    #FFFFFF;
    --c-surface-2:  #F9F8F5;
    --c-border:     #E4E0D8;
    --c-border-2:   #D4CFC4;

    --c-text:       #1C1A16;
    --c-text-2:     #5C5649;
    --c-text-3:     #9C968A;

    --c-primary:    #2D5016;
    --c-primary-h:  #3D6B20;
    --c-primary-l:  #EAF0E3;
    --c-accent:     #C8956C;
    --c-accent-l:   #FAF0E9;

    --c-incident:   #C0392B;
    --c-incident-l: #FCEAE9;
    --c-tache:      #1A6B3A;
    --c-tache-l:    #E8F5EE;
    --c-idee:       #9B5E00;
    --c-idee-l:     #FFF3E0;

    --radius:       10px;
    --radius-lg:    16px;
    --shadow:       0 2px 12px rgba(0,0,0,.07);
    --shadow-md:    0 4px 24px rgba(0,0,0,.10);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.14);

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body:    'DM Sans', system-ui, sans-serif;

    --sidebar-w:    260px;
    --topbar-h:     64px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-h); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--c-primary);
    background-image: linear-gradient(180deg, #2D5016 0%, #1E3A0F 100%);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-logo {
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo .logo-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: .01em;
    line-height: 1.2;
}
.sidebar-logo .logo-sub {
    font-size: .72rem;
    color: rgba(255,255,255,.5);
    text-transform: uppercase;
    letter-spacing: .12em;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
    padding: 12px 16px 4px;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: rgba(255,255,255,.35);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 400;
    transition: all .15s;
    position: relative;
    border-radius: 0;
    margin: 1px 10px;
    border-radius: 8px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,.15);
    color: #fff;
    font-weight: 500;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--c-accent);
    border-radius: 0 2px 2px 0;
}
.nav-badge {
    margin-left: auto;
    background: var(--c-accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--c-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
    font-size: .8rem;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user .user-role {
    font-size: .68rem;
    color: rgba(255,255,255,.45);
    text-transform: capitalize;
}
.sidebar-user .logout-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.4);
    padding: 4px;
    border-radius: 4px;
    transition: color .15s;
}
.sidebar-user .logout-btn:hover { color: #fff; }
.sidebar-user .logout-btn svg { width: 16px; height: 16px; }

/* --- Main content --- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-h);
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 90;
}
.topbar-title {
    flex: 1;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--c-text);
    letter-spacing: .01em;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    color: var(--c-text-2);
    border-radius: 6px;
}
.menu-toggle svg { width: 22px; height: 22px; }
.menu-toggle:hover { background: var(--c-surface-2); }

/* --- Page content --- */
.page-content {
    padding: 28px;
    flex: 1;
}

/* --- Flash messages --- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.flash-success { background: var(--c-tache-l); color: var(--c-tache); border: 1px solid #B8DFC8; }
.flash-error   { background: var(--c-incident-l); color: var(--c-incident); border: 1px solid #F5C6C2; }
.flash-info    { background: var(--c-primary-l); color: var(--c-primary); border: 1px solid #C8D9B8; }

/* --- Stat cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--c-text-3);
    font-weight: 600;
    margin-bottom: 8px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1;
    color: var(--c-text);
}
.stat-sub {
    font-size: .75rem;
    color: var(--c-text-3);
    margin-top: 4px;
}
.stat-card.accent .stat-value { color: var(--c-accent); }
.stat-card.primary .stat-value { color: var(--c-primary); }
.stat-card.danger .stat-value { color: var(--c-incident); }

/* --- Cards & panels --- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--c-text);
}
.card-body { padding: 20px; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: .855rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}
.btn-primary:hover { background: var(--c-primary-h); border-color: var(--c-primary-h); color: #fff; }
.btn-secondary {
    background: var(--c-surface);
    color: var(--c-text-2);
    border-color: var(--c-border-2);
}
.btn-secondary:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-accent {
    background: var(--c-accent);
    color: #fff;
    border-color: var(--c-accent);
}
.btn-accent:hover { background: #B87A50; color: #fff; }
.btn-danger {
    background: #fff;
    color: var(--c-incident);
    border-color: #E8C0BD;
}
.btn-danger:hover { background: var(--c-incident-l); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }
.btn-icon { padding: 8px; gap: 0; }

/* --- Badges statuts --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.badge-nouveau    { background: #E3F2FD; color: #1565C0; }
.badge-affecte    { background: #FFF3E0; color: #E65100; }
.badge-en-cours   { background: #E8F5E9; color: #2E7D32; }
.badge-en-attente { background: #F3E5F5; color: #6A1B9A; }
.badge-arbitrer   { background: #FFF8E1; color: #F57F17; }
.badge-resolu     { background: #E0F2F1; color: #00695C; }
.badge-cloture    { background: #EFEBE9; color: #4E342E; }
.badge-rejete     { background: #FCE4EC; color: #880E4F; }

/* --- Type tags --- */
.type-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 500;
}
.type-incident { background: var(--c-incident-l); color: var(--c-incident); }
.type-tache    { background: var(--c-tache-l);    color: var(--c-tache); }
.type-idee     { background: var(--c-idee-l);     color: var(--c-idee); }

/* --- Priority dots --- */
.prio-basse   { color: var(--c-text-3); }
.prio-normale { color: var(--c-primary); }
.prio-haute   { color: var(--c-accent); }
.prio-urgente { color: var(--c-incident); font-weight: 600; }

/* --- Table --- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}
.table th {
    background: var(--c-surface-2);
    padding: 10px 14px;
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--c-text-3);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table .ref { font-family: monospace; font-size: .78rem; color: var(--c-text-3); }
.table .fiche-title { font-weight: 500; color: var(--c-text); }
.table .fiche-title small { display: block; font-size: .75rem; font-weight: 400; color: var(--c-text-3); }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--c-text-2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.form-label .req { color: var(--c-incident); margin-left: 2px; }
.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--c-border-2);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: .9rem;
    color: var(--c-text);
    background: var(--c-surface);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-l);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C5649' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: .75rem; color: var(--c-text-3); margin-top: 5px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* --- Radio type selector --- */
.type-selector { display: flex; gap: 10px; }
.type-option input { display: none; }
.type-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1.5px solid var(--c-border-2);
    border-radius: 10px;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 500;
    transition: all .15s;
    color: var(--c-text-2);
}
.type-option input:checked + label.type-incident { border-color: var(--c-incident); background: var(--c-incident-l); color: var(--c-incident); }
.type-option input:checked + label.type-tache    { border-color: var(--c-tache);    background: var(--c-tache-l);    color: var(--c-tache); }
.type-option input:checked + label.type-idee     { border-color: var(--c-idee);     background: var(--c-idee-l);     color: var(--c-idee); }
.type-option label:hover { border-color: var(--c-primary); }

/* --- Filters bar --- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filters-bar .form-control { width: auto; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--c-text-3); pointer-events: none; }
.search-input-wrap input { padding-left: 34px; }

/* --- Timeline commentaires --- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
    display: flex;
    gap: 12px;
    padding-bottom: 20px;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 16px; top: 36px; bottom: 0;
    width: 1px;
    background: var(--c-border);
}
.timeline-item:last-child::before { display: none; }
.timeline-avatar {
    width: 33px; height: 33px;
    border-radius: 50%;
    background: var(--c-primary-l);
    color: var(--c-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    z-index: 1;
}
.timeline-bubble {
    flex: 1;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 10px 14px;
}
.timeline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: .78rem;
    color: var(--c-text-3);
}
.timeline-meta strong { color: var(--c-text-2); font-weight: 600; }
.timeline-bubble p { font-size: .88rem; }
.timeline-event {
    background: none;
    border: none;
    padding: 4px 0;
}
.timeline-event .timeline-meta { margin: 0; }

/* --- Photos grid --- */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.photo-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--c-border);
    cursor: pointer;
    transition: transform .15s;
}
.photo-thumb:hover { transform: scale(1.03); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--c-text-3);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: .5;
}
.empty-state h3 { font-size: .95rem; color: var(--c-text-2); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}
.page-btn {
    min-width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    font-size: .82rem;
    border: 1px solid transparent;
    color: var(--c-text-2);
    background: none;
    transition: all .12s;
}
.page-btn:hover { background: var(--c-surface); border-color: var(--c-border-2); color: var(--c-text); }
.page-btn.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* --- Login page --- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1E3A0F 0%, #2D5016 60%, #3D6B20 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--c-surface);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-main {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--c-primary);
    line-height: 1.1;
}
.login-logo .logo-sub {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--c-text-3);
    margin-top: 4px;
}
.login-divider {
    width: 40px; height: 2px;
    background: var(--c-accent);
    margin: 12px auto;
    border-radius: 2px;
}

/* --- Fiche detail --- */
.fiche-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.fiche-header-left .fiche-ref {
    font-family: monospace;
    font-size: .8rem;
    color: var(--c-text-3);
    margin-bottom: 4px;
}
.fiche-header-left h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.2;
}
.fiche-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

.detail-field {
    padding: 12px 0;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    gap: 16px;
}
.detail-field:last-child { border-bottom: none; }
.detail-field .label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--c-text-3);
    min-width: 120px;
    padding-top: 2px;
}
.detail-field .value { color: var(--c-text); font-size: .9rem; }

/* --- Overlay --- */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* --- Responsive --- */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .page-content { padding: 16px; }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .type-selector { flex-wrap: wrap; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar { padding: 0 16px; }
    .topbar-title { font-size: 1.1rem; }
    .fiche-header { flex-direction: column; }
}

/* --- Utilities --- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.text-sm { font-size: .82rem; }
.text-muted { color: var(--c-text-3); }
.text-right { text-align: right; }
.fw-medium { font-weight: 500; }
.w-full { width: 100%; }
