/* ==========================================================================
   PersonalOS - Visual Design System (CSS Only)
   macOS + Apple Fitness + Linear Inspired Theme
   ========================================================================== */

:root {
  /* Core Palette (Dark Theme Base) */
  --bg-app: #0b0f17;
  --bg-sidebar: #090d13;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(24, 32, 50, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.16);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;

  --accent-color: #3b82f6;
  --success: #34d399;
  --danger: #ef4444;

  /* Semantic Module Colors */
  --color-finance: #34D399;
  --color-finance-soft: rgba(52, 211, 153, 0.12);

  --color-tasks: #60A5FA;
  --color-tasks-soft: rgba(96, 165, 250, 0.12);

  --color-goals: #A78BFA;
  --color-goals-soft: rgba(167, 139, 250, 0.12);

  --color-focus: #FB923C;
  --color-focus-soft: rgba(251, 146, 60, 0.12);

  --color-bike: #22D3EE;
  --color-bike-soft: rgba(34, 211, 238, 0.12);

  --color-travel: #F472B6;
  --color-travel-soft: rgba(244, 114, 182, 0.12);

  /* System Font Stack */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-app: #f3f4f6;
  --bg-sidebar: #e5e7eb;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(0, 0, 0, 0.15);
  
  --text-main: #111827;
  --text-muted: #4b5563;
  --text-subtle: #9ca3af;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  /* Ambient Background Glow */
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(167, 139, 250, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(52, 211, 153, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
}

/* ==================== LAYOUT ==================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}

.brand h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
  padding: 0 12px 20px 12px;
}

.brand span {
  color: var(--accent-color);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
  color: var(--text-main);
  border: 1px solid rgba(59, 130, 246, 0.2);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.nav-item .icon {
  font-size: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active .icon {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-color);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-top: auto;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.user-status {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - 260px);
  overflow-y: auto;
}

.view {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.view-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 4px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* Header Date Badge */
.header-date-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.header-date-badge .date-icon {
  font-size: 18px;
}

.header-date-badge .date-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.header-date-badge .date-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== CARDS & CONTAINERS ==================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-color-hover);
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* Semantic Card Accents (Top Border Glows) */
#dashboard-finance-preview, [data-view="finance"] .form-card { border-top: 3px solid var(--color-finance); }
#dashboard-tasks-preview, [data-view="tasks"] .form-card { border-top: 3px solid var(--color-tasks); }
#dashboard-goals-preview, [data-view="goals"] .form-card { border-top: 3px solid var(--color-goals); }
#dashboard-travel-preview, [data-view="travel"] .form-card { border-top: 3px solid var(--color-travel); }
#dashboard-bike-preview { border-top: 3px solid var(--color-bike); }
.focus-card { border-top: 3px solid var(--color-focus); }

/* ==================== STAT CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-color-hover);
  background: var(--bg-card-hover);
}

.stat-card:nth-child(1) { border-left: 3px solid var(--color-finance); }
.stat-card:nth-child(2) { border-left: 3px solid var(--color-tasks); }
.stat-card:nth-child(3) { border-left: 3px solid var(--color-goals); }
.stat-card:nth-child(4) { border-left: 3px solid var(--color-focus); }

.stat-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.stat-card:nth-child(1) .stat-icon-box { background: var(--color-finance-soft); color: var(--color-finance); }
.stat-card:nth-child(2) .stat-icon-box { background: var(--color-tasks-soft); color: var(--color-tasks); }
.stat-card:nth-child(3) .stat-icon-box { background: var(--color-goals-soft); color: var(--color-goals); }
.stat-card:nth-child(4) .stat-icon-box { background: var(--color-focus-soft); color: var(--color-focus); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 8px;
}

.stat-val {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-subtle);
}

/* ==================== DASHBOARD GRID ==================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.content-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .content-split {
    grid-template-columns: 1fr;
  }
  .main-content {
    max-width: 100vw;
    padding: 20px;
  }
  .sidebar {
    width: 70px;
    padding: 16px 8px;
  }
  .sidebar .brand h2,
  .sidebar .user-meta,
  .sidebar .nav-item span:not(.icon) {
    display: none;
  }
  .sidebar .nav-item {
    justify-content: center;
    padding: 12px;
  }
}

/* Card Header Components */
.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-icon-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.card-action-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.card-action-link:hover {
  color: var(--text-main);
}

.card-inner-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 14px;
  transition: all 0.2s ease;
  display: block;
  text-align: center;
  text-decoration: none;
}

.card-inner-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-color-hover);
}

/* ==================== FORM CONTROLS & INPUTS ==================== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: rgba(0, 0, 0, 0.3);
}

textarea {
  resize: vertical;
}

/* Settings View Forms Alignment Fix */
#view-settings form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

#view-settings .form-group {
  flex: 1;
  min-width: 180px;
  margin-bottom: 0 !important;
}

#view-settings button[type="submit"] {
  height: 41px;
  flex-shrink: 0;
  margin-top: auto;
}

/* ==================== BUTTONS ==================== */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-color), #2563eb);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-color-hover);
}

/* ==================== PROGRESS BARS ==================== */
progress {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--color-goals), var(--color-travel));
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ==================== SETTINGS SECTION ACCENTS ==================== */
#view-settings .card:nth-child(1) { border-left: 3px solid var(--color-tasks); }
#view-settings .card:nth-child(2) { border-left: 3px solid var(--color-finance); }
#view-settings .card:nth-child(3) { border-left: 3px solid var(--color-goals); }
#view-settings .card:nth-child(4) { border-left: 3px solid var(--color-bike); }
#view-settings .card:nth-child(5) { border-left: 3px solid var(--text-muted); }

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}