/* Global Stylesheet & Design System - Campus Expense Tracker */

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

:root {
  /* Light Theme Variables - Premium Vibrant */
  --primary-hue: 260;
  --primary-color: hsl(var(--primary-hue), 85%, 55%);
  --primary-hover: hsl(var(--primary-hue), 85%, 45%);
  --primary-light: hsl(var(--primary-hue), 85%, 96%);
  --primary-glow: rgba(124, 58, 237, 0.25);

  --bg-color: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-border: rgba(226, 232, 240, 0.9);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;

  /* Refined Semantic Colors */
  --success-color: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-color: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger-color: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --info-color: #0ea5e9;

  --nav-bg: rgba(255, 255, 255, 0.75);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
  /* Dark Theme Variables - Deep & Sleek */
  --primary-color: hsl(var(--primary-hue), 90%, 65%);
  --primary-hover: hsl(var(--primary-hue), 90%, 75%);
  --primary-light: rgba(139, 92, 246, 0.15);
  --primary-glow: rgba(167, 139, 250, 0.35);

  --bg-color: #020617; /* Slate 950 */
  --card-bg: rgba(15, 23, 42, 0.65); /* Slate 900 with transparency */
  --card-border: rgba(255, 255, 255, 0.06);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --nav-bg: rgba(2, 6, 23, 0.75);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.8);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

html, body {
  min-height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

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

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.glass-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

/* App Header & Navigation Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 260px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 1.5rem 1rem;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.nav-item a:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

.nav-item.active a {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.nav-item a i {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

/* Sidebar Footer & Theme Toggle */
.sidebar-footer {
  border-top: 1px solid var(--card-border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-main);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--primary-light);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  height: 70px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title h1 {
  font-size: 1.4rem;
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.live-clock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-color);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: var(--transition-normal);
}

.live-clock-badge i {
  color: var(--primary-color);
  font-size: 0.9rem;
  animation: pulseClock 2s infinite ease-in-out;
}

.live-clock-badge .clock-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

@keyframes pulseClock {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 2px 8px var(--primary-glow);
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.main-content {
  padding: 2rem;
  flex: 1;
}

/* Form Controls & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-color);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Primary & Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
  opacity: 0.95;
}

.btn-secondary {
  background: var(--card-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

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

.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-income {
  background: var(--success-bg);
  color: var(--success-color);
}

.badge-expense {
  background: var(--danger-bg);
  color: var(--danger-color);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s ease forwards;
}

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

.toast.success i { color: var(--success-color); }
.toast.error i { color: var(--danger-color); }
.toast.warning i { color: var(--warning-color); }

/* Modal Backdrop & Dialog */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 500px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-fast);
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Mobile Toggle Hamburger */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}

/* ----------------------------------------------------------------
   #15 Empty State Styling
---------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.empty-state svg {
  color: var(--text-muted);
  opacity: 0.6;
}

.empty-state-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  padding: 2rem;
}

.empty-state-chart p {
  font-size: 0.9rem;
}

/* ----------------------------------------------------------------
   #16 Undo Toast Button
---------------------------------------------------------------- */
.undo-btn {
  margin-left: 0.75rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--warning-color);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: opacity var(--transition-fast);
  white-space: nowrap;
}

.undo-btn:hover { opacity: 0.85; }

/* ----------------------------------------------------------------
   #2 Notes Display in Table & Widget
---------------------------------------------------------------- */
.trans-notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
}

.trans-notes-cell {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  cursor: help;
}

/* ----------------------------------------------------------------
   #11 Print-Friendly Report Styles
---------------------------------------------------------------- */
@media print {
  .sidebar,
  .top-bar,
  .mobile-nav-toggle,
  #export-pdf-btn,
  #export-csv-btn,
  #print-report-btn,
  .sidebar-footer,
  .btn {
    display: none !important;
  }

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

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }

  .glass-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: white !important;
    break-inside: avoid;
    margin-bottom: 1rem;
  }

  .analytics-metrics-grid,
  .metrics-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
  }

  @page {
    margin: 1.5cm;
  }
}
