/* ============================================
   PhotoCalendar v2.4 - LOD Corporation
   Main Stylesheet
   ============================================ */

:root {
  --primary:      #4361ee;
  --primary-dark: #3a0ca3;
  --success:      #10b981;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --sidebar-w:    260px;
  --topnav-h:     64px;
  --transition:   0.25s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 0.925rem; }

/* ============================================
   LIGHT THEME
   ============================================ */
body.theme-light {
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #1e293b;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: rgba(255,255,255,0.15);
  --sidebar-hover:  rgba(255,255,255,0.08);
  --topnav-bg: #ffffff;
  --topnav-border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.05);
}

/* ============================================
   DARK THEME
   ============================================ */
body.theme-dark,
[data-bs-theme="dark"] body,
body.theme-dark [data-bs-theme="dark"] {
  --bg:       #0f172a;
  --surface:  #1e293b;
  --surface2: #1a2540;
  --border:   #334155;
  --text:     #e2e8f0;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: rgba(255,255,255,0.7);
  --sidebar-active: rgba(67,97,238,0.3);
  --sidebar-hover:  rgba(255,255,255,0.05);
  --topnav-bg: #1e293b;
  --topnav-border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
}

/* Dark theme overrides for Bootstrap */
[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
}

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

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

.page-content {
  padding: 1.75rem;
  flex: 1;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow: hidden;
  transition: transform var(--transition), width var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: var(--topnav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-logo {
  max-height: 42px;
  max-width: 170px;
  object-fit: contain;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-brand i {
  font-size: 1.4rem;
  color: var(--primary);
  background: rgba(67,97,238,0.15);
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-version {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.nav-section {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 0.5rem 0.75rem 0.25rem;
  margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  color: var(--sidebar-text);
  border-radius: 10px;
  margin-bottom: 2px;
  transition: all var(--transition);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

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

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: white;
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.75rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
}

/* ============================================
   TOP NAVBAR
   ============================================ */
.topnav {
  height: var(--topnav-h);
  background: var(--topnav-bg);
  border-bottom: 1px solid var(--topnav-border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--topnav-border);
}

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px; height: 38px;
  border-radius: 10px;
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }

.page-title { color: var(--text); font-size: 1.05rem; }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px; height: 38px;
  border-radius: 10px;
  transition: all var(--transition);
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

.user-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.35rem 0.75rem;
  transition: all var(--transition);
}
.user-btn:hover { background: var(--bg); }

/* ============================================
   AVATARS
   ============================================ */
.avatar-sm {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 700;
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  opacity: 0.08;
}

.stat-card.stat-primary { border-left: 4px solid var(--primary); }
.stat-card.stat-primary::before { background: var(--primary); }
.stat-card.stat-success { border-left: 4px solid var(--success); }
.stat-card.stat-success::before { background: var(--success); }
.stat-card.stat-danger { border-left: 4px solid var(--danger); }
.stat-card.stat-danger::before { background: var(--danger); }
.stat-card.stat-info { border-left: 4px solid var(--info); }
.stat-card.stat-info::before { background: var(--info); }
.stat-card.stat-warning { border-left: 4px solid var(--warning); }
.stat-card.stat-warning::before { background: var(--warning); }

.stat-icon {
  font-size: 1.4rem;
  opacity: 0.8;
}
.stat-card.stat-primary .stat-icon { color: var(--primary); }
.stat-card.stat-success .stat-icon { color: var(--success); }
.stat-card.stat-danger .stat-icon  { color: var(--danger); }
.stat-card.stat-info .stat-icon    { color: var(--info); }
.stat-card.stat-warning .stat-icon { color: var(--warning); }

.stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--surface);
  border-color: var(--border) !important;
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.card-footer {
  border-top: 1px solid var(--border);
}

/* ============================================
   TABLES
   ============================================ */
.table { --bs-table-color: var(--text); --bs-table-bg: var(--surface); }
.table thead th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.table td { vertical-align: middle; border-color: var(--border); }
.table-hover tbody tr:hover { background: var(--bg); }

/* DataTables */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted); }
.dataTables_wrapper .paginate_button { border-radius: 6px !important; }

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  border-radius: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.15);
}
.form-label { font-weight: 600; font-size: 0.875rem; color: var(--text); }
.form-text { color: var(--text-muted); }
.input-group-text { background: var(--bg); border-color: var(--border); color: var(--text-muted); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  border-radius: 8px;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(67,97,238,0.3); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

/* ============================================
   MODALS
   ============================================ */
.modal-content {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
}
.modal-header {
  border-bottom: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
}
.modal-footer { border-top: 1px solid var(--border); }
.btn-close { filter: var(--bs-btn-close-color, none); }
[data-bs-theme="dark"] .btn-close { filter: invert(1); }

/* ============================================
   DROPDOWNS
   ============================================ */
.dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 0.5rem;
}
.dropdown-item { border-radius: 8px; color: var(--text); padding: 0.5rem 0.85rem; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-divider { border-color: var(--border); }
.dropdown-item-text { padding: 0.3rem 0.85rem; color: var(--text); }

/* ============================================
   BADGES
   ============================================ */
.badge { border-radius: 6px; font-weight: 600; }
.fw-mono { font-family: monospace; }

/* ============================================
   CALENDAR (FullCalendar)
   ============================================ */
.fc { --fc-border-color: var(--border); --fc-today-bg-color: rgba(67,97,238,0.08); }
.fc .fc-button { border-radius: 8px !important; }
.fc .fc-button-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.fc .fc-toolbar-title { font-size: 1.1rem !important; font-weight: 700; }
.fc .fc-daygrid-day-number { color: var(--text); }
.fc .fc-col-header-cell { background: var(--bg); }
.fc .fc-event { border-radius: 6px; font-size: 0.78rem; font-weight: 600; }
[data-bs-theme="dark"] .fc .fc-daygrid-day-number { color: var(--text); }
[data-bs-theme="dark"] .fc .fc-col-header-cell { background: var(--surface2); }
[data-bs-theme="dark"] .fc-theme-standard td, [data-bs-theme="dark"] .fc-theme-standard th { border-color: var(--border); }

/* ============================================
   CATEGORY DOT
   ============================================ */
.cat-color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   ALERT
   ============================================ */
.alert { border-radius: 12px; border: none; }
.alert-success { background: rgba(16,185,129,0.12); color: #065f46; }
.alert-danger  { background: rgba(239,68,68,0.12); color: #991b1b; }
.alert-warning { background: rgba(245,158,11,0.12); color: #92400e; }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-content {
    margin-left: 0 !important;
  }
}

/* Sidebar collapsed */
body.sidebar-collapsed .sidebar { width: 70px; }
body.sidebar-collapsed .main-content { margin-left: 70px; }
body.sidebar-collapsed .sidebar-nav .nav-link span,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .sidebar-version,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-brand span { display: none; }
body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; }

/* ============================================
   FLATPICKR Dark
   ============================================ */
[data-bs-theme="dark"] .flatpickr-calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
[data-bs-theme="dark"] .flatpickr-day { color: var(--text); }
[data-bs-theme="dark"] .flatpickr-day.selected { background: var(--primary); border-color: var(--primary); }
[data-bs-theme="dark"] .flatpickr-months .flatpickr-month { color: var(--text); }

/* ============================================
   OFFER PREVIEW
   ============================================ */
#offerPreview {
  background: white;
  color: #1f2937;
  min-height: 400px;
  border-radius: 0 0 8px 8px;
}
[data-bs-theme="dark"] #offerPreview { background: white; }

/* ============================================
   SWEETALERT2
   ============================================ */
[data-bs-theme="dark"] .swal2-popup {
  background: var(--surface);
  color: var(--text);
}

/* ============================================
   SCROLL
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   UTILITIES
   ============================================ */
.text-primary { color: var(--primary) !important; }
.min-w-0 { min-width: 0; }

/* Print */
@media print {
  .sidebar, .topnav, .btn, .modal { display: none !important; }
  .main-content { margin-left: 0 !important; }
}
