/* assets/css/app.css - Styles principaux RepairTrack */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;
  --transition-speed: 0.2s;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ============ TYPO ============ */
body { font-family: var(--font-sans); font-size: 0.925rem; }
.font-monospace { font-family: 'JetBrains Mono', 'Fira Code', monospace !important; }

/* ============ DARK THEME OVERRIDES ============ */
[data-bs-theme="dark"] {
  --bs-body-bg: #0f1117;
  --bs-body-color: #e2e8f0;
  --card-bg: #1a1d27;
  --sidebar-bg: #141620;
  --topbar-bg: #141620;
  --border-color: rgba(255,255,255,0.07);
  --hover-bg: rgba(255,255,255,0.04);
  --input-bg: #1e2130;
}

[data-bs-theme="light"] {
  --bs-body-bg: #f0f4f8;
  --bs-body-color: #1a2332;
  --card-bg: #ffffff;
  --sidebar-bg: #1a2332;
  --topbar-bg: #ffffff;
  --border-color: rgba(0,0,0,0.08);
  --hover-bg: rgba(0,0,0,0.03);
  --input-bg: #ffffff;
}

/* ============ LAYOUT ============ */
.wrapper { min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-nav { list-style: none; padding: 0.5rem 0.75rem; margin: 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--bs-body-color);
  opacity: 0.7;
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-speed);
  font-size: 0.875rem;
  margin-bottom: 2px;
}

.sidebar-nav .nav-link:hover { opacity: 1; background: var(--hover-bg); }
.sidebar-nav .nav-link.active { opacity: 1; background: rgba(var(--bs-primary-rgb), 0.12); color: var(--bs-primary); }
.sidebar-nav .nav-link i { font-size: 1.05rem; flex-shrink: 0; }

.sidebar-divider {
  padding: 0.25rem 1.25rem;
  margin: 0.25rem 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.4;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

/* ============ SEARCH ============ */
.search-wrapper { position: relative; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.4;
  z-index: 2;
  pointer-events: none;
}
.search-input {
  padding-left: 2.25rem;
  background: var(--input-bg) !important;
  border-color: var(--border-color) !important;
  border-radius: 8px !important;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}
.search-results.show { display: block; }
.search-result-group { padding: 0.5rem 0.75rem 0.25rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.5; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition-speed);
  text-decoration: none;
  color: inherit;
}
.search-result-item:hover { background: var(--hover-bg); }

/* ============ CARDS ============ */
.card {
  background: var(--card-bg) !important;
  border-color: var(--border-color) !important;
  border-radius: 12px !important;
}
.card-header { border-color: var(--border-color) !important; }

.stat-card { transition: transform 0.15s, box-shadow 0.15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.75rem; opacity: 0.6; margin-top: 2px; }

/* ============ TABLES ============ */
.table { --bs-table-bg: transparent; }
.table-hover > tbody > tr:hover > * { background: var(--hover-bg); }
.cursor-pointer { cursor: pointer; }

/* ============ BADGES ============ */
.badge { font-weight: 500; }

/* ============ FORMS ============ */
.form-control, .form-select {
  background-color: var(--input-bg) !important;
  border-color: var(--border-color) !important;
  border-radius: 8px !important;
}
.form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.15) !important;
}
.input-group .form-control { border-radius: 0 !important; }
.input-group > :first-child { border-radius: 8px 0 0 8px !important; }
.input-group > :last-child { border-radius: 0 8px 8px 0 !important; }

/* ============ BUTTONS ============ */
.btn { border-radius: 8px !important; font-weight: 500; }
.btn-sm { font-size: 0.8125rem; }

/* ============ LOGIN ============ */
.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { border-radius: 16px !important; background: var(--card-bg) !important; }
.login-logo { width: 64px; height: 64px; background: rgba(var(--bs-primary-rgb), 0.12); border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }

/* ============ USER AVATAR ============ */
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(var(--bs-primary-rgb), 0.15);
  color: var(--bs-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem; flex-shrink: 0;
}
.user-avatar-sm {
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(var(--bs-primary-rgb), 0.15);
  color: var(--bs-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; flex-shrink: 0;
}
.user-menu-btn { border: none !important; background: transparent !important; padding: 2px !important; }

/* ============ AUTOCOMPLETE ============ */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  z-index: 500;
  max-height: 250px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition-speed);
}
.autocomplete-item:hover { background: var(--hover-bg); }

/* ============ NOTES ============ */
.note-item { border-left: 3px solid var(--border-color); padding-left: 0.75rem; }
.note-internal { border-left-color: var(--bs-warning) !important; }
.note-content a { color: var(--bs-primary); text-decoration: underline; }

/* ============ UPLOAD DROPZONE ============ */
.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  transition: all var(--transition-speed);
  cursor: pointer;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.05);
}

/* ============ PEC CARD ============ */
.pec-card { transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; }
.pec-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important; }

/* ============ PAGINATION ============ */
.pagination { flex-wrap: wrap; gap: 4px; }
.page-link { border-radius: 6px !important; border: 1px solid var(--border-color) !important; padding: 0.3rem 0.65rem; font-size: 0.875rem; }

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  background: transparent !important;
  padding: 0.375rem 0.6rem;
}

/* ============ SIDEBAR TOGGLE (MOBILE) ============ */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 1050;
    transform: translateX(-100%);
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
  }
  .sidebar-overlay.show { display: block; }
}

/* ============ PAGE CONTENT ============ */
.page-content { min-height: calc(100vh - var(--topbar-height)); }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.5); }

/* ===== FIX LAYOUT GLOBAL ===== */

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.main-content {
  flex: 1 1 auto;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  background: var(--bs-body-bg);
}

.page-content {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar-section-label {
  padding: 0.85rem 1.25rem 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.45;
  font-weight: 700;
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(var(--bs-primary-rgb), 0.15);
  color: var(--bs-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  color: var(--bs-body-color);
  white-space: nowrap;
}

.sidebar-user-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--bs-body-color);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 10px;
}

.sidebar-user-link:hover {
  background: var(--hover-bg);
}

.user-info {
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-sub {
  font-size: 0.75rem;
  opacity: 0.55;
}

.btn-ghost {
  color: var(--bs-body-color) !important;
  border: 1px solid transparent !important;
  background: transparent !important;
}

.btn-ghost:hover {
  background: var(--hover-bg) !important;
  border-color: var(--border-color) !important;
}

.topbar {
  position: sticky;
  top: 0;
  flex-shrink: 0;
}

.sidebar-nav li {
  list-style: none;
}

@media (max-width: 991.98px) {
  .main-content {
    width: 100%;
  }
}