:root {
  --bg-color: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-sidebar: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --border-color: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(12px);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 8px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links a:hover, .nav-links a.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem 4rem;
  overflow-y: auto;
}

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

h1 {
  font-size: 2rem;
  font-weight: 600;
}

.btn {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.5);
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 10px -1px rgba(59, 130, 246, 0.6);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Cards Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-Nouveau { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.status-En.cours { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-Réponses.reçues, .status-Terminé, .status-Envoyé, .status-Répondu { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-À.envoyer { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }

/* Table */
.table-container {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1.25rem 1.5rem;
  text-align: left;
}

th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  border-top: 1px solid var(--border-color);
  font-size: 0.95rem;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Back Link */
.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.5rem;
  transition: color 0.3s;
}

.back-link:hover {
  color: var(--text-primary);
}

/* Toast Notification */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--accent-color);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease forwards, fadeOut 0.5s ease 3s forwards;
  opacity: 0;
  transform: translateX(100%);
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.success {
  border-left-color: var(--success);
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.attachments-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.attachments-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.attachments-list li a {
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.9rem;
}
.attachments-list li a:hover {
  text-decoration: underline;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}
.drop-zone.dragover {
    border-color: var(--accent-color);
    background: rgba(52, 152, 219, 0.1);
}
.drop-zone-content {
    pointer-events: none;
}


/* ==========================================================================
   Responsive & Mobile Styles
   ========================================================================== */

/* Hamburger menu button (hidden on desktop) */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
}



/* ==========================================================================
   Responsive & Mobile Styles
   ========================================================================== */

/* Hamburger menu button (hidden on desktop) */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    /* Sidebar becomes a bottom navigation bar or an off-canvas menu */
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-sidebar);
    }

    .brand {
        margin-bottom: 0;
    }
    
    .brand-icon {
        display: none;
    }
    
    .brand span {
        display: none; /* Hide text on very small screens to save space */
    }

    .mobile-menu-btn {
        display: block;
    }

    /* Hide nav links by default on mobile, show via toggle class */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--bg-sidebar);
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }

    .nav-links.show {
        display: flex;
    }

    .main-content {
        padding: 1rem;
        width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 2rem;
        width: 100%;
    }

    .header-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem !important;
    }

    .grid {
        grid-template-columns: 1fr;
        width: 100%;
    }

    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        width: 100%;
    }

    /* Adjust cards for mobile tap targets */
    .btn {
        width: 100%;
        justify-content: center;
        padding: 1rem; /* Larger tap target */
    }
    
    header .btn {
        width: 100%;
    }
    
    .drop-zone {
        padding: 1.5rem;
        width: 100%;
    }
}

/* Light Theme Variables and Overrides */
body.light-theme {
  --bg-color: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-sidebar: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .brand span {
  color: #0f172a;
}

body.light-theme .nav-links a {
  color: #475569;
}

body.light-theme .nav-links a:hover, body.light-theme .nav-links a.active {
  background: rgba(15, 23, 42, 0.05);
  color: #0f172a;
}

body.light-theme .card:hover {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.06);
  border-color: rgba(15, 23, 42, 0.15);
}

body.light-theme input, body.light-theme select, body.light-theme textarea, body.light-theme .form-control {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid rgba(15, 23, 42, 0.15) !important;
  color: #0f172a !important;
}

body.light-theme th {
  background: rgba(0, 0, 0, 0.03);
  color: #475569;
}

body.light-theme .btn.secondary {
  background: rgba(0, 0, 0, 0.05) !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

body.light-theme .btn.secondary:hover {
  background: rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .status-Nouveau { background: rgba(37, 99, 235, 0.12) !important; color: #1d4ed8 !important; }
body.light-theme .status-En.cours { background: rgba(217, 119, 6, 0.12) !important; color: #b45309 !important; }
body.light-theme .status-Réponses.reçues, body.light-theme .status-Terminé, body.light-theme .status-Envoyé, body.light-theme .status-Répondu { background: rgba(5, 150, 105, 0.12) !important; color: #047857 !important; }
body.light-theme .status-À.envoyer { background: rgba(0, 0, 0, 0.05) !important; color: #475569 !important; }

body.light-theme .back-link {
  color: #2563eb !important;
}

/* Concessionaires & Users Mobile List & Cards */
.concessionaires-mobile-list, .users-mobile-list {
  display: none;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.concessionaire-card, .user-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.concessionaire-card-header, .user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.concessionaire-name, .user-email {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
  word-break: break-all;
}

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
body.light-theme .badge.success {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
}

.badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
body.light-theme .badge.warning {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.concessionaire-card-body, .user-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.info-row.status-row {
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
}

.info-row .label, .attachments-section .label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.info-row .value {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-all;
}

.attachments-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Settings Responsive Grid */
@media (max-width: 768px) {
  .table-container {
    display: none !important;
  }
  
  .concessionaires-mobile-list, .users-mobile-list {
    display: flex !important;
  }
  
  /* Fix settings grid on mobile */
  div[style*="display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr))"] {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  div[style*="display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr))"] .card {
    max-width: 100% !important;
    width: 100% !important;
  }
}


