/* ═══════════════════════════════════════
   SubClear — Design System (Light Theme)
   ═══════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+JP:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  /* Colors */
  --primary: #F97316; /* Orange 500 */
  --primary-dark: #EA580C; /* Orange 600 */
  --primary-light: #FFF7ED; /* Orange 50 */
  --primary-rgb: 249, 115, 22;
  --accent: #475569; /* Slate 600 */
  --accent-light: #F8FAFC; /* Slate 50 */
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --success: #3F3F46; /* Zinc 700 instead of green */
  --success-light: #F4F4F5; /* Zinc 100 */
  --info: #52525B; /* Zinc 600 instead of blue */

  /* Neutrals */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E4E4E7;
  --border-light: #F4F4F5;
  --text: #18181B;
  --text-secondary: #52525B;
  --text-muted: #A1A1AA;

  /* Category Colors */
  --cat-work: #EA580C;
  --cat-entertainment: #F97316;
  --cat-productivity: #71717A;
  --cat-learning: #52525B;
  --cat-health: #3F3F46;
  --cat-other: #A1A1AA;

  /* Typography */
  --font: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

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

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --max-width: 1200px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--duration) var(--ease); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Layout: App Shell ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.3s var(--ease);
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.app-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-content {
  padding: var(--space-xl);
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar-logo {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
}

.sidebar-logo span {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-lg);
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 var(--space-md);
  margin-bottom: var(--space-xs);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.6rem var(--space-md);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
}

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

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-link i { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Page Header ── */
.page-header {
  margin-bottom: var(--space-xl);
}

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

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.card-change {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.card-change.up { background: var(--danger-light); color: var(--danger); }
.card-change.down { background: var(--success-light); color: var(--success); }

/* ── Summary Cards Grid ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}



.summary-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
  background: var(--border-light);
  color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(var(--primary-rgb), 0.3);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #DC2626; color: #fff; }

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

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ── Forms ── */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-input.is-error,
.form-select.is-error {
  border-color: var(--danger);
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: var(--space-xs);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ── Subscription Cards ── */
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.sub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease);
  position: relative;
}

.sub-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sub-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.sub-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  flex-shrink: 0;
}

.sub-name {
  font-size: 1rem;
  font-weight: 600;
}

.sub-category {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.sub-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

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

.sub-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-md);
}

.sub-next-billing {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sub-days {
  font-weight: 700;
  color: var(--primary);
}

/* Mottainai Badge */
.mottainai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: #B45309;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid #FDE68A;
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.status-badge.--active { background: var(--success-light); color: var(--success); }
.status-badge.--paused { background: var(--border-light); color: var(--text-secondary); }
.status-badge.--cancelled { background: var(--bg); color: var(--text-muted); }

/* ── Calendar ── */
.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.calendar-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
  padding: var(--space-sm);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.calendar-day {
  min-height: 80px;
  padding: var(--space-xs);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.calendar-day:nth-child(7n) { border-right: none; }

.calendar-day-number {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 2px 6px;
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
}

.calendar-day.other-month {
  background: var(--bg);
}

.calendar-event {
  font-size: 0.65rem;
  padding: 2px 4px;
  border-radius: 3px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
}

.calendar-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Alerts / Flash Messages ── */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid var(--border); }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #FECACA; }
.alert-warning { background: var(--accent-light); color: var(--text); border: 1px solid var(--border); }
.alert-info { background: var(--border-light); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 0.75rem var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover td { background: var(--bg); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  padding: var(--space-xl);
  transform: scale(0.95);
  transition: transform 0.2s var(--ease);
}

.modal-overlay.show .modal { transform: scale(1); }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.hidden { display: none !important; }

/* ── Responsive ── */
.sidebar-toggle { display: none; }

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .app-content {
    padding: var(--space-md);
  }
  .sidebar-toggle {
    display: flex;
  }
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sub-grid {
    grid-template-columns: 1fr;
  }
}

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

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.3s var(--ease) forwards;
}

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

.count-up {
  animation: countUp 0.5s var(--ease) forwards;
}

/* ── Auth Pages (Login/Register) ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-xl);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: var(--space-xs);
  color: var(--primary);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: var(--space-xs);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Landing Page ── */
.lp-hero {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
  padding: var(--space-2xl);
}

.lp-hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.lp-hero h1 span {
  color: var(--primary);
}

.lp-hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto var(--space-xl);
}

/* ── Responsive & Mobile Menu ── */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .app-main {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: inline-flex;
  }
}

@media (min-width: 769px) {
  .sidebar-toggle {
    display: none !important;
  }
}
