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

/* Post-link forms (inline POST navigation) */
.post-link-form { display:inline; margin:0; padding:0; }
.post-link-form .post-link { background:none; border:none; padding:0; margin:0; font:inherit; color:var(--primary); cursor:pointer; text-decoration:none; font-weight:700; }
.post-link-form .post-link:hover { text-decoration:underline; }

/* =====================================================
   RESET & VARIABLES
   ===================================================== */
:root {
    --primary: #1A5276;
    --primary-light: #2E86C1;
    --primary-gradient: linear-gradient(135deg, #1A5276, #2E86C1);
    --secondary: #2980B9;
    --success: #1E8449;
    --danger: #C0392B;
    --warning: #D68910;
    --info: #2E86C1;
    --bg-main: #F0F2F5;
    --bg-sidebar: #0B1E2D;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --text-primary: #1A1D21;
    --text-secondary: #6B7280;
    --white: #FFFFFF;
    --brown: #6E3B1A;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --sidebar-width: 270px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', 'Segoe UI', -apple-system, sans-serif;
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--secondary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
}

/* =====================================================
   LAYOUT
   ===================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg-main);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition-slow);
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

.content-area {
    padding: 28px 32px;
    min-height: calc(100vh - var(--header-height));
    max-width: 1600px;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 40%);
    color: var(--white);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: var(--transition-slow);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-header .logo {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.sidebar-header .site-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar.collapsed .sidebar-header .site-name,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-arrow {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 16px 8px;
}

.sidebar.collapsed .sidebar-header .logo {
    width: 48px;
    height: 48px;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.35);
    padding: 20px 14px 8px;
}

.nav-subsection-title {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.4);
    padding: 12px 16px 4px 32px;
}
.nav-subsection-title:first-child {
    padding-top: 6px;
}
.sidebar.collapsed .nav-subsection-title {
    display: none;
}

/* =====================================================
   Boîte d'actions (inbox dashboard)
   ===================================================== */
.inbox-card {
    margin-bottom: 20px;
}
.inbox-list {
    display: flex;
    flex-direction: column;
}
.inbox-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item:hover { background: var(--bg-light); }
.inbox-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.inbox-icon-info     { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.inbox-icon-warning  { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.inbox-icon-danger   { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.inbox-icon-success  { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.inbox-body { flex: 1; min-width: 0; }
.inbox-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.inbox-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.inbox-arrow {
    color: var(--text-secondary);
    font-size: 0.75rem;
}
@media (max-width: 768px) {
    .inbox-item { padding: 12px 14px; }
    .inbox-title { font-size: 0.88rem; }
}

/* =====================================================
   Bouton submit sticky bas (formulaires longs)
   ===================================================== */
.form-submit-sticky {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    margin: 20px -16px 0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    z-index: 10;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}
@media (max-width: 1024px) {
    .form-submit-sticky {
        margin: 16px -16px 0;
    }
}

.nav-item {
    display: block;
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 9px 14px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.875rem;
    font-weight: 450;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    border-left: none;
    cursor: pointer;
    gap: 11px;
    position: relative;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-link.active {
    background: rgba(46, 134, 193, 0.18);
    color: #ffffff;
    font-weight: 500;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary-light);
}

.nav-link .nav-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.95rem;
    opacity: 0.85;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    opacity: 1;
}

.nav-link .nav-text {
    flex: 1;
    white-space: nowrap;
}

.nav-link .nav-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.nav-link .nav-arrow.open {
    transform: rotate(90deg);
}

/* Sous-menu */
.nav-submenu {
    display: none;
    padding-left: 8px;
    margin-top: 2px;
}

.nav-submenu.open {
    display: block;
}

.nav-submenu .nav-link {
    padding: 7px 14px 7px 40px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
}

.nav-submenu .nav-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.nav-submenu .nav-link.active {
    color: #fff;
    background: rgba(46, 134, 193, 0.12);
}

.sidebar.collapsed .nav-submenu {
    display: none !important;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 8px;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 10px;
    flex-shrink: 0;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    z-index: 500;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-main);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: var(--border);
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Header right */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-search {
    position: relative;
}

.header-search input {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 16px 6px 36px;
    font-size: 0.85rem;
    width: 220px;
    transition: var(--transition);
    font-family: var(--font);
    outline: none;
}

.header-search input:focus {
    border-color: var(--primary-light);
    width: 280px;
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.1);
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Notifications bell */
.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.notification-bell:hover {
    background: var(--bg-main);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Notifications dropdown */
.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: none;
    z-index: 1100;
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown.show {
    display: block;
}

.notification-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-main);
    transition: var(--transition);
    display: flex;
    gap: 10px;
}

.notification-item:hover {
    background: var(--bg-main);
}

.notification-item.unread {
    background: rgba(46, 134, 193, 0.04);
}

.notification-item .notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.notification-item .notif-icon.info { background: rgba(46, 134, 193, 0.15); color: var(--info); }
.notification-item .notif-icon.success { background: rgba(30, 132, 73, 0.15); color: var(--success); }
.notification-item .notif-icon.warning { background: rgba(214, 137, 16, 0.15); color: var(--warning); }
.notification-item .notif-icon.danger { background: rgba(192, 57, 43, 0.15); color: var(--danger); }

.notification-item .notif-content {
    flex: 1;
    min-width: 0;
}

.notification-item .notif-title {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.notification-item .notif-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* User dropdown */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: var(--transition);
    background: none;
    border: none;
    font-family: var(--font);
    color: var(--text-primary);
}

.user-menu-trigger:hover {
    background: var(--bg-main);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-menu-trigger .user-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.user-menu-trigger .user-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: none;
    z-index: 1100;
    margin-top: 4px;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.user-dropdown a:hover {
    background: var(--bg-main);
}

.user-dropdown .divider {
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.user-dropdown a.text-danger {
    color: var(--danger);
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    border-color: transparent;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.primary { background: rgba(26, 82, 118, 0.1); color: var(--primary); }
.stat-card .stat-icon.success { background: rgba(30, 132, 73, 0.1); color: var(--success); }
.stat-card .stat-icon.warning { background: rgba(214, 137, 16, 0.1); color: var(--warning); }
.stat-card .stat-icon.danger { background: rgba(192, 57, 43, 0.1); color: var(--danger); }
.stat-card .stat-icon.info { background: rgba(46, 134, 193, 0.1); color: var(--info); }

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-primary { background: rgba(26, 82, 118, 0.1); color: var(--primary); }
.badge-success { background: rgba(30, 132, 73, 0.1); color: var(--success); }
.badge-warning { background: rgba(214, 137, 16, 0.1); color: var(--warning); }
.badge-danger { background: rgba(192, 57, 43, 0.1); color: var(--danger); }
.badge-info { background: rgba(46, 134, 193, 0.1); color: var(--info); }
.badge-secondary { background: rgba(107, 114, 128, 0.1); color: var(--text-secondary); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 4px rgba(26, 82, 118, 0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #2E86C1, #1A5276);
    color: #fff;
    box-shadow: 0 4px 8px rgba(26, 82, 118, 0.3);
}

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

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

.btn-warning {
    background: var(--warning);
    color: var(--white);
}
.btn-warning:hover {
    background: #e67e22;
    color: var(--white);
}

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

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

.table-styled {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.table-styled thead th {
    background: var(--bg-main);
    color: var(--text-primary);
    padding: 11px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--border);
}

.table-styled thead th:first-child {
    border-radius: var(--radius) 0 0 0;
}

.table-styled thead th:last-child {
    border-radius: 0 var(--radius) 0 0;
}

.table-styled tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

.table-styled tbody tr {
    transition: var(--transition);
}

.table-styled tbody tr:hover {
    background: rgba(46, 134, 193, 0.03);
}

.table-styled .actions {
    white-space: nowrap;
    text-align: right;
}
.table-styled .actions > * {
    margin-right: 4px;
    vertical-align: middle;
}
.table-styled .actions > *:last-child {
    margin-right: 0;
}

.table-styled .text-right {
    text-align: right;
}

.table-styled .text-center {
    text-align: center;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-primary);
    background-color: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.12);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    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='%237F8C8D' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
}

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

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

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

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

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    gap: 12px;
    border-left: 4px solid;
}

.alert-success { background: rgba(30, 132, 73, 0.08); color: var(--success); border-left-color: var(--success); }
.alert-danger { background: rgba(192, 57, 43, 0.08); color: var(--danger); border-left-color: var(--danger); }
.alert-warning { background: rgba(214, 137, 16, 0.08); color: var(--warning); border-left-color: var(--warning); }
.alert-info { background: rgba(46, 134, 193, 0.08); color: var(--info); border-left-color: var(--info); }

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

.alert-close:hover {
    opacity: 1;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show,
.modal-overlay.active {
    display: flex;
}

/* Standalone modal (used as overlay directly with .active toggle) */
.modal[id^="modal-"] {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 0;
    box-shadow: none;
    overflow-y: hidden;
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: modalOverlayIn 0.25s ease;
}

.modal[id^="modal-"].active {
    display: flex;
}

.modal[id^="modal-"] > .modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 8px 20px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal[id^="modal-"] > .modal-content form {
    display: flex;
    flex-direction: column;
    max-height: calc(85vh - 65px);
}

.modal[id^="modal-"] > .modal-content form > .modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal[id^="modal-"] > .modal-content form > .modal-footer {
    flex-shrink: 0;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 8px 20px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(46, 134, 193, 0.04), rgba(46, 134, 193, 0.01));
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
    background: rgba(192, 57, 43, 0.1);
}

/* Cancel button in modal footer — restore btn styles over modal-close reset */
.modal-footer .btn.modal-close {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: auto;
    height: auto;
    font-size: inherit;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-weight: 600;
}
.modal-footer .btn.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-row,
.modal-body .modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

.modal-body .form-row > .form-group.full-width,
.modal-body .modal-form-grid > .form-group.full-width {
    grid-column: 1 / -1;
}

.modal-body .grid-2 {
    gap: 16px;
}

.modal-body .form-group {
    margin-bottom: 14px;
}

.modal-body .form-group label,
.modal-body .form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.modal-body .form-control {
    border-radius: var(--radius-md, 8px);
    border: 1.5px solid var(--border);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.15);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-main);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Mécanique — Autocomplete dropdown */
/* Generic autocomplete */
.autocomplete-list {
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    z-index: 9999;
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    max-height: 220px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: .9em;
    border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-hover); }

.meca-autocomplete-list {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    z-index: 9999;
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    max-height: 200px;
    overflow-y: auto;
}
.meca-ac-item {
    background: var(--bg-card, #1e293b);
}
.meca-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: .9em;
    border-bottom: 1px solid var(--border);
}
.meca-ac-item:last-child { border-bottom: none; }
.meca-ac-item:hover { background: var(--bg-hover); }
.meca-ac-item.meca-ac-empty { color: var(--text-muted); cursor: default; }

#meca-lignes-table input.form-control {
    padding: 4px 8px;
    min-height: unset;
}
#meca-lignes-table td { vertical-align: middle; }

/* Scrollbar inside modal */
.modal::-webkit-scrollbar,
.modal[id^="modal-"] > .modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-thumb,
.modal[id^="modal-"] > .modal-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb:hover,
.modal[id^="modal-"] > .modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 28px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--white);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.page-link:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(46, 134, 193, 0.25);
}

.page-link.active {
    background: var(--primary-gradient);
    color: var(--white);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(46, 134, 193, 0.3);
}

.page-dots {
    padding: 0 6px;
    color: var(--text-secondary);
}

/* =====================================================
   CITIZEN SEARCH DROPDOWN
   ===================================================== */
.citizen-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-xl); max-height: 280px; overflow-y: auto; display: none;
}
.citizen-item {
    padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.citizen-item:last-child { border-bottom: none; }
.citizen-item:hover { background: var(--bg-light); }
.citizen-item-empty {
    padding: 14px; text-align: center; color: var(--text-secondary); font-size: 13px;
}
.citizen-selected-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3);
    border-radius: 8px; padding: 8px 14px; font-size: 14px; color: var(--text-primary);
}
.citizen-selected-badge i { color: #22c55e; }
.btn-clear-citizen {
    background: none; border: none; color: var(--text-secondary); font-size: 18px;
    cursor: pointer; padding: 0 4px; line-height: 1;
}
.btn-clear-citizen:hover { color: var(--danger); }

[data-theme="dark"] .citizen-dropdown {
    background: #1e293b; border-color: #334155;
}
[data-theme="dark"] .citizen-item:hover { background: #334155; }
[data-theme="dark"] .citizen-selected-badge {
    background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.4);
}

/* =====================================================
   TIMELINE
   ===================================================== */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--border) 100%);
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2.5px solid var(--white);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-item .timeline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.timeline-item .timeline-content {
    font-size: 0.9rem;
}

/* =====================================================
   TABS
   ===================================================== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    gap: 4px;
    overflow-x: auto;
}

.tab-link {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
    white-space: nowrap;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-link:hover {
    color: var(--primary);
    background: rgba(46, 134, 193, 0.04);
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-header .page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =====================================================
   SEARCH BAR
   ===================================================== */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    padding: 11px 16px 11px 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
    background: var(--white);
}

.search-bar input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.1);
}

.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* =====================================================
   DROPDOWN
   ===================================================== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    min-width: 200px;
    display: none;
    z-index: 1100;
    margin-top: 6px;
    padding: 4px 0;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a,
.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 16px;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    transition: var(--transition);
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background: var(--bg-main);
    color: var(--primary);
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-primary { color: var(--primary) !important; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

.hidden {
    display: none !important;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #061520 0%, #0B1E2D 40%, #1B4F72 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(46,134,193,0.15) 0%, transparent 70%);
    top: -150px;
    right: -100px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(93,173,226,0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -80px;
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-card .login-logo {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    margin: 0 auto 20px;
    border: 3px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.login-card .login-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 36px;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 1rem;
    margin-top: 12px;
    font-weight: 600;
}

.login-error {
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border-left: 3px solid var(--danger);
}

/* =====================================================
   SIDEBAR OVERLAY (mobile)
   ===================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* =====================================================
   Overlay sombre pour sidebar mobile/tablette
   ===================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}
.sidebar-overlay.active {
    display: block;
}

/* =====================================================
   RESPONSIVE (Tablette)
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-area {
        padding: 20px 16px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .tabs {
        gap: 0;
    }

    .tab-link {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .table-styled {
        font-size: 0.8rem;
    }

    .table-styled th,
    .table-styled td {
        padding: 10px 12px;
    }

    .modal,
    .modal[id^="modal-"] > .modal-content {
        width: 96%;
        max-height: 95vh;
    }
}

/* Print styles */
@media print {
    .sidebar, .header, .filters-bar, .btn, .pagination {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-area {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =====================================================
   DARK MODE
   ===================================================== */
[data-theme="dark"] {
    --bg-main: #0f1923;
    --bg-sidebar: #0a1219;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --text-primary: #e0e6ed;
    --text-secondary: #8899a6;
    --white: #1a2736;
    --border: #253545;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.5);
    --primary: #3B9FD8;
    --primary-light: #5DADE2;
    --primary-gradient: linear-gradient(135deg, #2E86C1 0%, #5DADE2 100%);
    --secondary: #5DADE2;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #5DADE2;
}

[data-theme="dark"] .sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
}

[data-theme="dark"] .header {
    background: rgba(26, 39, 54, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

[data-theme="dark"] .form-control {
    background-color: #1a2736;
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.15);
}

[data-theme="dark"] select.form-control {
    background: #1a2736 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='%238899a6' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center / 12px;
    color: var(--text-primary);
}

[data-theme="dark"] select.form-control option {
    background: #1a2736;
    color: var(--text-primary);
}

[data-theme="dark"] .header-search input {
    background: #1a2736;
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .notification-dropdown,
[data-theme="dark"] .user-dropdown,
[data-theme="dark"] .dropdown-menu {
    background: #1a2736;
    border-color: var(--border);
}

[data-theme="dark"] .notification-item:hover,
[data-theme="dark"] .user-dropdown a:hover,
[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .dropdown-menu button:hover {
    background: #253545;
}

[data-theme="dark"] .table-styled tbody tr:hover {
    background: rgba(46, 134, 193, 0.08);
}

[data-theme="dark"] .modal {
    background: #1a2736;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .modal[id^="modal-"] {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .modal[id^="modal-"] > .modal-content {
    background: #1a2736;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .modal-header {
    background: linear-gradient(135deg, rgba(46, 134, 193, 0.08), rgba(46, 134, 193, 0.02));
}

[data-theme="dark"] .modal-footer {
    background: rgba(15, 25, 35, 0.5);
}

[data-theme="dark"] .modal::-webkit-scrollbar-thumb,
[data-theme="dark"] .modal[id^="modal-"] > .modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .modal::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .modal[id^="modal-"] > .modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .login-page {
    background: linear-gradient(135deg, #050d14 0%, #0a1219 40%, #152a3a 100%);
}

[data-theme="dark"] .login-card {
    background: rgba(26, 39, 54, 0.95);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

[data-theme="dark"] .filters-bar {
    background: var(--white);
}

[data-theme="dark"] .timeline-item::before {
    border-color: #1a2736;
}

[data-theme="dark"] .page-link {
    background: var(--white);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .page-link:hover {
    box-shadow: 0 2px 8px rgba(46, 134, 193, 0.3);
}

[data-theme="dark"] .page-link.active {
    box-shadow: 0 2px 8px rgba(46, 134, 193, 0.35);
}

[data-theme="dark"] .stat-card::before {
    opacity: 0.15;
}

[data-theme="dark"] .sidebar-overlay {
    background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .alert-success { background: rgba(46, 204, 113, 0.1); }
[data-theme="dark"] .alert-danger { background: rgba(231, 76, 60, 0.1); }
[data-theme="dark"] .alert-warning { background: rgba(243, 156, 18, 0.1); }
[data-theme="dark"] .alert-info { background: rgba(93, 173, 226, 0.1); }

/* Dark mode toggle */
.dark-mode-toggle {
    background: none;
    border: 1px solid var(--border);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 7px;
    border-radius: var(--radius);
    transition: var(--transition);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.dark-mode-toggle:hover {
    background: var(--bg-main);
    color: var(--primary);
    border-color: var(--primary-light);
}

/* ============================================================
   ESPACE ENTREPRISE (workspace : annonces / discussions / commandes)
   ============================================================ */
.espace-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 16px;
}
.espace-ident { display: flex; align-items: center; gap: 14px; }
.espace-logo {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em;
}
.espace-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.espace-sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.espace-presence { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.espace-duty-count { font-size: 0.85rem; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.dot-online { width: 9px; height: 9px; border-radius: 50%; background: var(--success); display: inline-block; }

.espace-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.espace-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500; color: var(--text-secondary);
    background: var(--white); border: 1px solid var(--border);
    text-decoration: none; transition: var(--transition);
}
.espace-tab:hover { color: var(--primary); border-color: var(--primary-light); }
.espace-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.espace-compose { margin-bottom: 16px; }

/* Annonces */
.espace-annonce { margin-bottom: 12px; }
.espace-annonce.pinned { border-left: 3px solid var(--warning); }
.espace-annonce-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.espace-annonce-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.espace-annonce-body { color: var(--text-primary); font-size: 0.92rem; line-height: 1.55; }
.espace-annonce-foot { margin-top: 10px; font-size: 0.82rem; }
.espace-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--bg-main); color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.78rem;
}

/* Discussions */
.espace-chat { padding: 0; overflow: hidden; }
.espace-chat-stream {
    display: flex; flex-direction: column; gap: 14px;
    padding: 18px; height: 420px; overflow-y: auto;
}
.espace-chat-empty { text-align: center; color: var(--text-secondary); margin: auto; }
.emsg { display: flex; gap: 10px; max-width: 80%; }
.emsg.me { margin-left: auto; flex-direction: row-reverse; }
.emsg-body { background: var(--bg-main); border-radius: 12px; padding: 8px 12px; }
.emsg.me .emsg-body { background: var(--primary); color: #fff; }
.emsg.me .emsg-body .emsg-time, .emsg.me .emsg-body strong { color: #fff; }
.emsg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; font-size: 0.82rem; }
.emsg-time { color: var(--text-secondary); font-size: 0.72rem; }
.emsg-text { font-size: 0.9rem; line-height: 1.45; word-break: break-word; }
.espace-chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.espace-chat-form .form-control { flex: 1; }

/* Commandes */
.espace-order { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.espace-order.closed { opacity: 0.6; }
.espace-order-ref { font-size: 0.78rem; font-weight: 700; color: var(--text-secondary); width: 64px; flex-shrink: 0; }
.espace-order-main { flex: 1; min-width: 180px; }
.espace-order-title { font-weight: 600; color: var(--text-primary); }
.espace-order-sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.espace-order-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.espace-order-claim { font-size: 0.8rem; color: var(--text-secondary); }
.espace-order-actions { display: flex; gap: 4px; }

/* ============================================================
   MESSAGERIE
   ============================================================ */

/* Badge non-lus sidebar */
.nav-badge {
    background: var(--danger);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: auto;
}

/* Toolbar (select all, actions) */
.msg-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
    border-radius: var(--radius) var(--radius) 0 0;
}
.msg-checkbox-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Message list */
.msg-list {
    display: flex;
    flex-direction: column;
}
.msg-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    text-decoration: none;
}
.msg-row:hover {
    background: var(--bg-main);
}
.msg-row.msg-unread {
    background: rgba(52, 152, 219, 0.04);
    border-left: 3px solid var(--primary);
}
.msg-check {
    flex-shrink: 0;
}
.msg-content {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}
.msg-content:hover {
    text-decoration: none;
}
.msg-sender {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.msg-company-tag {
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 4px;
}
.msg-subject {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-preview {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-date {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.msg-read-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Compose form */
.msg-compose-form .form-group {
    margin-bottom: 1.25rem;
}
.msg-recipient-input {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.msg-recipient-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 42px;
    cursor: text;
    flex: 1;
}
.msg-recipient-chips:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.msg-chip-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    flex: 1;
    min-width: 120px;
    padding: 0.15rem 0;
}
.msg-chip-input::placeholder {
    color: var(--text-muted);
}
.msg-compose-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.8rem;
    white-space: nowrap;
    line-height: 1.4;
}
.msg-compose-chip i {
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.chip-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.1rem;
    line-height: 1;
    font-weight: 700;
    opacity: 0.7;
}
.chip-remove:hover {
    opacity: 1;
    color: var(--danger);
}
    color: var(--danger);
}
.msg-compose-form textarea {
    min-height: 200px;
    resize: vertical;
    font-family: inherit;
}

/* Message detail */
.msg-detail-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
}
.msg-detail-subject {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
.msg-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.msg-role-tag {
    font-size: 0.75rem;
    background: var(--bg-main);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 0.25rem;
}
.msg-detail-body {
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 1rem 0;
    min-height: 100px;
}
.msg-detail-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    margin-top: 1.5rem;
}
.msg-detail-recipients-list {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.msg-detail-recipients-list h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.msg-recipients-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.msg-recipient-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.82rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
}
.msg-recipient-chip.read {
    color: var(--success);
}
.msg-recipient-chip.unread {
    color: var(--text-muted);
}

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

/* ============================================================
   RICH TEXT EDITOR
   ============================================================ */

.msg-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-wrap: wrap;
}
.editor-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
    line-height: 1;
}
.editor-btn:hover {
    background: var(--white);
    border-color: var(--border);
    color: var(--primary);
}
.editor-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.msg-editor-content {
    min-height: 220px;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--white);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
}
.msg-editor-content:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}
.msg-editor-content ul, .msg-editor-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}
.msg-editor-content blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
}

/* ============================================================
   FILE UPLOAD / ATTACHMENTS
   ============================================================ */

.msg-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.msg-file-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.msg-file-item i.fa-file-pdf { color: #e74c3c; }
.msg-file-item i.fa-file-image { color: #3498db; }
.msg-file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
    font-size: 0.8rem;
    line-height: 1;
}
.msg-file-remove:hover { color: var(--danger); }

/* Attachments in message detail */
.msg-attachments-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.msg-attachments-section h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.msg-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.msg-attachment-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: 180px;
    background: var(--bg-main);
    transition: var(--transition);
}
.msg-attachment-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.msg-attachment-preview {
    display: block;
    height: 120px;
    overflow: hidden;
    background: var(--bg-main);
}
.msg-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.msg-attachment-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    color: var(--text-muted);
    text-decoration: none;
}
.msg-attachment-icon:hover { color: var(--primary); }
.msg-attachment-icon .fa-file-pdf { color: #e74c3c; }
.msg-attachment-info {
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
}
.msg-attachment-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}
.msg-attachment-name:hover { color: var(--primary); }
.msg-attachment-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Bloc cité (quoted-text) — visuel distinct dans les réponses/transferts */
.msg-detail-body blockquote.quoted-text,
.msg-editor-content blockquote.quoted-text {
    border-left: 3px solid var(--primary);
    padding: 8px 12px;
    margin: 8px 0;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
}
[data-theme="dark"] .msg-detail-body blockquote.quoted-text,
[data-theme="dark"] .msg-editor-content blockquote.quoted-text {
    background: rgba(255, 255, 255, 0.04);
}

/* Responsive */
@media (max-width: 768px) {
    .msg-recipient-input {
        flex-direction: column;
    }
    .msg-recipient-input select {
        width: 100% !important;
    }
    .msg-toolbar {
        flex-wrap: wrap;
    }
    .msg-detail-actions {
        flex-wrap: wrap;
    }
    .msg-attachment-card {
        width: 140px;
    }
    .msg-attachments-grid {
        gap: 0.5rem;
    }
    /* Toolbar éditeur simplifiée : masquer les boutons non-essentiels */
    .editor-desktop-only {
        display: none !important;
    }
    /* Dropdown autocomplete fullscreen-friendly */
    .autocomplete-results {
        max-height: 40vh;
        overflow-y: auto;
    }
    /* Sticky submit dans compose pour rester accessible avec clavier ouvert */
    .form-actions {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        padding: 12px 0;
        border-top: 1px solid var(--border);
        margin-top: 12px;
    }
}
