/* ==========================================================================
   HABITFLOW — PREMIUM DESIGN SYSTEM (Linear / Notion / Stripe Inspired)
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Colors */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-active: #3730A3;
  --primary-light: #EEF2FF;
  --primary-subtle: #E0E7FF;
  --primary-border: #C7D2FE;

  --accent-purple: #8B5CF6;
  --accent-blue: #3B82F6;
  --accent-cyan: #06B6D4;
  --accent-pink: #EC4899;

  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --surface-muted: #F1F5F9;

  --text: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --border: #E2E8F0;
  --border-focus: #4F46E5;
  --border-subtle: #F1F5F9;

  --success: #10B981;
  --success-light: #ECFDF5;
  --success-border: #A7F3D0;
  --success-dark: #047857;

  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-dark: #B45309;

  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --danger-border: #FECACA;
  --danger-dark: #B91C1C;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.03);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background-color: var(--bg);
}

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

a:hover {
  color: var(--primary-hover);
}

img, svg {
  display: inline-block;
  vertical-align: middle;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

h1 { font-size: 2.25rem; font-weight: 700; }
h2 { font-size: 1.75rem; font-weight: 600; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }

p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  line-height: 1.2;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

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

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

.btn-subtle:hover {
  background-color: var(--surface-muted);
  color: var(--text);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger-dark);
  border: 1px solid var(--danger-border);
}

.btn-danger:hover {
  background-color: #FEE2E2;
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background-color: var(--surface-muted);
  color: var(--text);
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
  overflow: hidden;
}

.card-hover:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-body {
  padding: 24px;
}

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

.card-header h3 {
  font-size: 1.1rem;
  margin: 0;
}

.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background-color: var(--bg);
}

/* Metric / KPI Card */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.metric-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: var(--success-light); color: var(--success-dark); }
.badge-warning { background-color: var(--warning-light); color: var(--warning-dark); }
.badge-danger { background-color: var(--danger-light); color: var(--danger-dark); }
.badge-neutral { background-color: var(--surface-muted); color: var(--text-secondary); border: 1px solid var(--border); }

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.9rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Checkbox Toggle */
.custom-checkbox {
  appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  background-color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
}

.custom-checkbox:checked {
  background-color: var(--success);
  border-color: var(--success);
}

.custom-checkbox:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid #FFFFFF;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Progress Bar */
.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background-color: var(--surface-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Alerts / Flash Messages */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: var(--success-dark); border-color: var(--success-border); }
.alert-danger { background: var(--danger-light); color: var(--danger-dark); border-color: var(--danger-border); }
.alert-info { background: var(--primary-light); color: var(--primary); border-color: var(--primary-border); }
.alert-warning { background: var(--warning-light); color: var(--warning-dark); border-color: var(--warning-border); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96) translateY(8px);
  transition: all var(--transition-normal);
  border: 1px solid var(--border);
}

.modal-overlay.active .modal-dialog {
  transform: scale(1) translateY(0);
}

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg);
}

/* Responsive Grid Helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

@media (max-width: 1024px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
