/* ============================================================
   Prudens Finance — Base Stylesheet
   Version: 2.0 (V2 — Inter font, sidebar layout, new colour scheme)
   ============================================================ */

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

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  /* Colours — V2 scheme */
  --color-primary:        #2563EB;
  --color-primary-dark:   #1D4ED8;
  --color-primary-alpha:  rgba(37, 99, 235, 0.12);

  --color-bg:             #F8F9FA;
  --color-bg-muted:       #F3F4F6;
  --color-surface:        #FFFFFF;
  --color-hover:          #F3F4F6;
  --color-border:         #E5E7EB;
  --color-border-light:   #F3F4F6;

  --color-text:           #111827;
  --color-text-muted:     #6B7280;

  --color-income:         #059669;
  --color-expense:        #DC2626;
  --color-danger:         #DC2626;
  --color-danger-light:   #FEF2F2;
  --color-badge-bg:       #F3F4F6;

  /* Sidebar */
  --sidebar-bg:           #1E2939;
  --sidebar-text:         #F1F5F9;
  --sidebar-text-muted:   #94A3B8;
  --sidebar-hover:        rgba(241, 245, 249, 0.08);
  --sidebar-active-bg:    rgba(37, 99, 235, 0.20);
  --sidebar-active-text:  #93C5FD;
  --sidebar-border:       rgba(241, 245, 249, 0.10);
  --sidebar-width:        220px;

  /* Typography */
  --font-family:          'Inter', sans-serif;

  /* Shadows */
  --shadow-sm:            0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:            0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg:            0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

  /* Spacing */
  --radius:               0.5rem;
  --radius-lg:            0.75rem;
  --radius-xl:            1rem;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT — SIDEBAR + CONTENT
   ============================================================ */

/* App shell — sidebar + main area side by side */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Main content area — offset by sidebar width */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  background: var(--color-bg);
}

/* ============================================================
   SIDEBAR INTERNALS
   ============================================================ */

/* Logo / brand area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.375rem 1.25rem 1.125rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.sidebar-brand-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sidebar-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: var(--sidebar-text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Nav links */
.sidebar-nav {
  flex: 1;
  padding: 0.875rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  margin: 0 0.5rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  letter-spacing: -0.005em;
  transition: background 0.15s, color 0.15s;
  position: relative;
  cursor: pointer;
}
.sidebar-nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  text-decoration: none;
}
.sidebar-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.sidebar-nav-item.active svg {
  color: var(--sidebar-active-text);
}

.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--sidebar-text-muted);
  transition: color 0.15s;
}
.sidebar-nav-item:hover svg {
  color: var(--sidebar-text);
}

.sidebar-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Section divider */
.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 0.5rem 1.25rem;
}

/* Bottom area — lang toggle + logout */
.sidebar-footer {
  padding: 0.875rem 0;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex-shrink: 0;
}

/* Language toggle inside sidebar */
.sidebar-lang {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  margin: 0 0.5rem;
  border-radius: var(--radius);
}
.sidebar-lang-label {
  font-size: 0.8125rem;
  color: var(--sidebar-text-muted);
  flex: 1;
}
.sidebar-lang-btns {
  display: flex;
  gap: 0.25rem;
}
.sidebar-lang-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-family);
  border-radius: 0.3rem;
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}
.sidebar-lang-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}
.sidebar-lang-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ============================================================
   MOBILE HAMBURGER + OVERLAY
   ============================================================ */

/* Hamburger button — only visible on mobile */
.sidebar-hamburger {
  display: none;
  position: fixed;
  top: 0.875rem;
  left: 0.875rem;
  z-index: 300;
  background: var(--sidebar-bg);
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  color: var(--sidebar-text);
}
.sidebar-hamburger svg {
  width: 20px;
  height: 20px;
}

/* Overlay when sidebar is open on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.25s;
}
.sidebar-overlay.visible {
  opacity: 1;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  .sidebar-hamburger {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-top: 3.5rem; /* space for hamburger button */
  }
}

/* ============================================================
   PAGE CONTAINERS
   ============================================================ */
.page-transactions,
.page-summary,
.page-nav,
.page-categories,
.page-settings,
.page-dashboard {
  max-width: 1100px;
  padding: 2rem 1.5rem 4rem;
  margin: 0 auto;
}

.page-settings {
  max-width: 780px;
}

/* ============================================================
   SHARED COMPONENTS — BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-hover);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  text-decoration: none;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.btn-sm {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.4rem;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-size: 1rem;
  line-height: 1;
  font-family: var(--font-family);
}
.btn-icon:hover {
  background: var(--color-hover);
  color: var(--color-text);
}
.btn-icon.danger:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* ============================================================
   SHARED COMPONENTS — CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   SHARED COMPONENTS — BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 99px;
  background: var(--color-badge-bg);
  color: var(--color-text-muted);
}
.badge-income {
  background: rgba(5,150,105,0.10);
  color: var(--color-income);
}
.badge-expense {
  background: rgba(220,38,38,0.10);
  color: var(--color-expense);
}

/* ============================================================
   SHARED COMPONENTS — PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--color-text);
}

/* ============================================================
   SHARED COMPONENTS — EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* ============================================================
   SHARED COMPONENTS — LOADING
   ============================================================ */
.loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SHARED COMPONENTS — FORM ELEMENTS
   ============================================================ */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.3125rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
textarea {
  resize: vertical;
  min-height: 80px;
}

/* ============================================================
   DASHBOARD TILES (index.php)
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.dashboard-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.375rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.dashboard-tile:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--color-text);
}

.dashboard-tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-primary-alpha);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}
.dashboard-tile-icon svg {
  width: 20px;
  height: 20px;
}

.dashboard-tile-name {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dashboard-tile-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Summary strip on dashboard */
.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.dashboard-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.dashboard-stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.dashboard-stat-value {
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--color-text);
}
.dashboard-stat-value.income { color: var(--color-income); }
.dashboard-stat-value.expense { color: var(--color-expense); }

@media (max-width: 540px) {
  .dashboard-summary {
    grid-template-columns: 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}
