/* ===== VARIABLES CSS ===== */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #059669;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  --dark-color: #1e293b;
  --light-color: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
}

/* ===== RESET ET BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--light-color);
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-wrapper {
  flex: 1;
  padding: 2rem 0;
}

/* ===== NAVIGATION ===== */
.navbar {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  box-shadow: var(--shadow);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  color: white;
  font-size: var(--font-size-xl);
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand:hover {
  color: var(--gray-100);
}

.navbar-nav {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  align-items: center;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-divider {
  color: rgba(255, 255, 255, 0.3);
  margin: 0 0.25rem;
}

/* ===== MESSAGES FLASH ===== */
.flash-messages {
  margin: 1rem 0;
}

.flash-message {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash-message.success {
  background-color: #d1fae5;
  color: #065f46;
  border-left-color: var(--success-color);
}

.flash-message.danger {
  background-color: #fee2e2;
  color: #991b1b;
  border-left-color: var(--danger-color);
}

.flash-message.warning {
  background-color: #fef3c7;
  color: #92400e;
  border-left-color: var(--warning-color);
}

.flash-message.info {
  background-color: #dbeafe;
  color: #1e40af;
  border-left-color: var(--primary-color);
}

/* ===== TYPOGRAPHIE ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--gray-900);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
  margin-bottom: 1rem;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.5rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.card-header h2 {
  margin: 0;
  color: var(--gray-900);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: white;
}

.btn-secondary {
  background-color: var(--gray-500);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--gray-600);
  color: white;
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-success:hover {
  background-color: #047857;
  color: white;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
  color: white;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  background-color: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: var(--font-size-lg);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--gray-900);
  background-color: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
  color: var(--gray-400);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* ===== TABLES ===== */
.table-container {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.table th {
  background-color: var(--gray-50);
  font-weight: 600;
  color: var(--gray-900);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody tr:hover {
  background-color: var(--gray-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: var(--font-size-sm); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container {
    padding: 0 0.5rem;
  }
  
  .navbar .container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .navbar-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .btn {
    font-size: var(--font-size-sm);
    padding: 0.375rem 0.75rem;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* ===== DASHBOARD SPECIFIQUE ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.quick-actions {
  list-style: none;
}

.quick-actions li {
  margin-bottom: 0.75rem;
}

.quick-actions a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--gray-700);
  transition: all 0.2s ease;
  border: 1px solid var(--gray-200);
}

.quick-actions a:hover {
  background-color: var(--gray-50);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* ===== PERMISSIONS MATRIX ===== */
.permissions-matrix {
  overflow-x: auto;
}

.permissions-matrix table {
  min-width: 600px;
}

.permissions-matrix select {
  min-width: 100px;
  padding: 0.25rem 0.5rem;
  font-size: var(--font-size-sm);
}

/* ===== LOGIN PAGE ===== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
}

.login-card {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-title {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--gray-900);
}

/* ===== ENHANCED CARD INTERACTIONS ===== */
.card {
  transition: box-shadow 0.2s, transform 0.13s;
  will-change: transform;
}
.card:hover, .card:focus-within {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px) scale(1.015);
  border: 1.5px solid var(--primary-color);
  outline: none;
}

/* ===== ENHANCED BUTTONS ===== */
.btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.25);
}
.btn:active {
  transform: scale(0.98);
}

/* ===== BADGES ENHANCED ===== */
.badge {
  transition: box-shadow 0.13s, transform 0.1s;
}
.badge:focus, .badge:hover {
  box-shadow: 0 2px 8px 0 rgba(37,99,235,0.08);
  transform: scale(1.07);
  outline: 2px solid var(--primary-color);
}

/* ===== DASHBOARD BACKGROUND ===== */
body {
  background-color: var(--gray-100);
}

/* ===== FLASH MESSAGE FADE-IN DOWN ===== */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px);}
  to { opacity: 1; transform: translateY(0);}
}
.flash-message {
  animation: fadeInDown 0.4s cubic-bezier(.51,1.13,.71,.93);
}

/* ===== QUICK-ACTION LINK ===== */
.quick-actions a {
  transition: box-shadow 0.18s, transform 0.13s, border-color 0.2s;
}
.quick-actions a:focus, .quick-actions a:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 16px 0 rgba(37,99,235,0.07);
  background: linear-gradient(92deg, #e0e7ff 0%, #f1f5ff 100%);
  transform: translateY(-1px) scale(1.015);
  outline: 2px solid var(--primary-color);
}

/* ===== CARDS GRID GAP ENHANCEMENT ===== */
.dashboard-grid {
  gap: 2rem;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.23);
  animation: ripple 0.5s linear;
  pointer-events: none;
  z-index: 1;
}
@keyframes ripple {
  to {
    transform: scale(2.5);
    opacity: 0;
  }
}
.btn {
  position: relative;
  overflow: hidden;
}
@media (min-width: 769px) {
  .navbar-nav {
    flex-direction: row !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    position: static !important;
    background: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
}


/* Burger visible en mobile uniquement */
.navbar-toggler {
  display: none;
  background: none;
  border: none;
  padding: 0.5em 0.8em;
  cursor: pointer;
  font-size: 1.7rem;
}
.navbar-toggler-icon {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  background: url("data:image/svg+xml,%3csvg width='28' height='28' viewBox='0 0 28 28' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3crect y='6' width='28' height='3' rx='1.5' fill='white'/%3e%3crect y='13' width='28' height='3' rx='1.5' fill='white'/%3e%3crect y='20' width='28' height='3' rx='1.5' fill='white'/%3e%3c/svg%3e") center/contain no-repeat;
}

/* En mobile, on passe en colonne, menu caché par défaut */
@media (max-width: 768px) {
  .navbar-toggler { display: block; }
  .navbar-nav {
    flex-direction: column;
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    gap: 0;
    align-items: stretch;
    padding: 0.5rem 1.2rem 1rem 1.2rem;
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.12);
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s;
    z-index: 2000;
  }
  .navbar-nav.open {
    display: flex;
    opacity: 1;
    pointer-events: auto;
  }
}
/* En desktop, on force le menu visible/horizontal */
@media (min-width: 769px) {
  .navbar-toggler { display: none !important; }
  .navbar-nav { display: flex !important; }
}


.theme-dark .table,
.theme-dark .table th,
.theme-dark .table td,
.theme-dark .table-container,
.theme-dark .card,
.theme-dark .card-header,
.theme-dark .card-body {
  background-color: #222840 !important;
  color: #e3e9fa !important;
  border-color: #353a53 !important;
}

.theme-dark .table th {
  background-color: #2c314d !important;
}

.theme-dark .table tbody tr:hover {
  background-color: #212641 !important;
}

.theme-dark #vaulty-tree {
  background-color: #23273c !important;
  color: #d3dbef !important;
  border-radius: 10px;
}
.theme-dark #vaulty-tree .list-group-item {
  background-color: transparent !important;
  color: #d3dbef !important;
  border-color: #2d3350 !important;
}

.theme-dark .list-group {
  background-color: #23273c !important;
  border-bottom: 1px solid #293150 !important;
}

.theme-dark #vaulty-tree .list-group-item {
  background-color: #23273c !important;
  border-bottom: 1px solid #293150 !important;
}

.theme-dark .list-group {
  --bs-list-group-bg: #23273c !important;
  --bs-list-group-color: #d3dbef !important;
}

.theme-dark .modal-content {
  background-color: transparent !important;
  color: #d3dbef !important;
  border-color: #2d3350 !important;
}

.theme-dark #vaulty-panel-content {
  background-color: #101424 !important;
  color: #d3dbef !important;
  border-color: #2d3350 !important;
}
