/* ============================================================================
   TinyInvoice Design System
   Hand-drawn, warm, paper-like aesthetic for invoicing that feels human
   ============================================================================ */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Kalam:wght@400;700&family=Patrick+Hand&display=swap');

/* ============================================================================
   CSS Variables - Color Palette & Spacing
   ============================================================================ */
:root {
  /* Colors */
  --color-paper: #fdfbf7;
  --color-ink: #2d2d2d;
  --color-accent: #ff6b6b;
  --color-cta: #fbbf24;
  --color-success: #10b981;
  --color-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-error: #ef4444;
  
  /* Fonts */
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-headline: 'Kalam', cursive;
  --font-label: 'Patrick Hand', cursive;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Border radius (organic, slightly irregular) */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(45, 45, 45, 0.08);
  --shadow-md: 0 4px 12px rgba(45, 45, 45, 0.12);
  --shadow-lg: 0 8px 24px rgba(45, 45, 45, 0.16);
  --shadow-paper: 2px 4px 8px rgba(45, 45, 45, 0.1);
}

/* ============================================================================
   Global Reset & Base Styles
   ============================================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-ink);
  background: var(--color-paper);
  background-image: 
    linear-gradient(90deg, rgba(45, 45, 45, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(45, 45, 45, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* ============================================================================
   Typography
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-ink);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #e55555;
}

label {
  font-family: var(--font-label);
  font-size: 0.95rem;
  color: var(--color-ink);
  margin-bottom: var(--space-xs);
  display: block;
}

/* ============================================================================
   Layout Components
   ============================================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-3xl) 0;
}

.section-alt {
  background: rgba(255, 107, 107, 0.03);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Flexbox Utilities */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ============================================================================
   Card Component (paper-like with subtle tilt)
   ============================================================================ */
.card {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-paper);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px) rotate(0deg);
  box-shadow: var(--shadow-lg);
}

.card-tilt {
  transform: rotate(-0.5deg);
}

.card-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px dashed var(--color-border);
}

.card-title {
  font-family: var(--font-headline);
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

/* ============================================================================
   Button Component (organic, hand-drawn feel)
   ============================================================================ */
.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--color-cta);
  color: var(--color-ink);
  border-color: var(--color-cta);
}

.btn-primary:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  color: var(--color-ink);
}

.btn-secondary {
  background: white;
  color: var(--color-ink);
  border-color: var(--color-ink);
}

.btn-secondary:hover {
  background: var(--color-ink);
  color: white;
}

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

.btn-accent:hover {
  background: #e55555;
  border-color: #e55555;
}

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

.btn-lg {
  font-size: 1.125rem;
  padding: 1rem 2rem;
}

.btn-sm {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ============================================================================
   Input Component (sketchy border)
   ============================================================================ */
.input-group {
  margin-bottom: var(--space-lg);
}

.input,
.textarea,
.select {
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input-error {
  border-color: var(--color-error);
}

.input-hint {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: var(--space-xs);
}

.input-error-msg {
  font-size: 0.875rem;
  color: var(--color-error);
  margin-top: var(--space-xs);
}

/* ============================================================================
   Badge Component (status indicators)
   ============================================================================ */
.badge {
  font-family: var(--font-label);
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  display: inline-block;
}

.badge-draft {
  background: #f3f4f6;
  color: #6b7280;
}

.badge-sent {
  background: #dbeafe;
  color: #1e40af;
}

.badge-viewed {
  background: #fef3c7;
  color: #92400e;
}

.badge-paid {
  background: #d1fae5;
  color: #065f46;
}

.badge-free {
  background: #f3f4f6;
  color: #6b7280;
}

.badge-pro {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

/* ============================================================================
   Table Component
   ============================================================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
}

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

.table th {
  font-family: var(--font-label);
  text-align: left;
  padding: 1rem;
  background: rgba(255, 107, 107, 0.05);
  border-bottom: 2px solid var(--color-border);
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: rgba(251, 191, 36, 0.05);
}

/* ============================================================================
   Navigation
   ============================================================================ */
.nav {
  background: white;
  border-bottom: 2px solid var(--color-border);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-headline);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-ink);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.nav-link {
  font-weight: 500;
  color: var(--color-ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: var(--color-accent);
}

/* ============================================================================
   Sidebar (for app.html)
   ============================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: white;
  border-right: 2px solid var(--color-border);
  padding: var(--space-lg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  font-family: var(--font-headline);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-ink);
  margin-bottom: var(--space-xl);
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sidebar-link {
  font-family: var(--font-body);
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--color-ink);
  text-decoration: none;
  transition: background 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 107, 107, 0.08);
  color: var(--color-accent);
}

.sidebar-link.active {
  background: rgba(251, 191, 36, 0.2);
  color: var(--color-ink);
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
}

/* ============================================================================
   Hero Section (landing page)
   ============================================================================ */
.hero {
  text-align: center;
  padding: var(--space-3xl) 0;
}

.hero-title {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--color-muted);
  margin-bottom: var(--space-xl);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================================
   Pricing Cards
   ============================================================================ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl);
  max-width: 800px;
  margin: 0 auto;
}

.pricing-card {
  background: white;
  border: 3px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  position: relative;
}

.pricing-card.featured {
  border-color: var(--color-cta);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.pricing-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--color-cta);
  color: var(--color-ink);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

.pricing-price {
  font-family: var(--font-headline);
  font-size: 2.5rem;
  margin: var(--space-md) 0;
}

.pricing-features {
  list-style: none;
  margin: var(--space-lg) 0;
  text-align: left;
}

.pricing-features li {
  padding: var(--space-sm) 0;
  border-bottom: 1px dashed var(--color-border);
}

.pricing-features li:last-child {
  border-bottom: none;
}

/* ============================================================================
   Comparison Table
   ============================================================================ */
.comparison-table {
  max-width: 900px;
  margin: 0 auto;
}

.comparison-table th {
  font-family: var(--font-headline);
  font-size: 1.125rem;
}

.comparison-check {
  color: var(--color-success);
  font-size: 1.25rem;
  font-weight: bold;
}

.comparison-cross {
  color: var(--color-muted);
  font-size: 1.25rem;
}

/* ============================================================================
   Footer
   ============================================================================ */
.footer {
  background: white;
  border-top: 2px solid var(--color-border);
  padding: var(--space-xl) 0;
  margin-top: var(--space-3xl);
  text-align: center;
}

.footer-text {
  color: var(--color-muted);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
  margin-top: var(--space-md);
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--color-muted); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.hidden { display: none; }

/* ============================================================================
   Toast Animation
   ============================================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   Mobile Hamburger Menu
   ============================================================================ */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  font-family: var(--font-body);
  color: var(--color-ink);
  transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
  background: var(--color-paper);
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: var(--shadow-lg);
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================================================
   Sidebar User Info (compact, right below nav)
   ============================================================================ */
.sidebar-user-info {
  padding-top: var(--space-lg);
  margin-top: var(--space-lg);
  border-top: 2px dashed var(--color-border);
}

/* ============================================================================
   Sidebar Upgrade Card (pinned to bottom of sidebar, desktop)
   ============================================================================ */
.sidebar-upgrade {
  margin-top: auto;
  background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
  border: 2px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-md) var(--space-md);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sidebar-upgrade::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.sidebar-upgrade-sparkle {
  font-size: 1.2rem;
  margin-bottom: 0.15rem;
  color: var(--color-cta);
}

.sidebar-upgrade-title {
  font-family: var(--font-headline);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.3rem;
}

.sidebar-upgrade-text {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
  margin: 0 0 0.65rem;
}

.sidebar-upgrade-text strong {
  color: var(--color-cta);
  font-weight: 700;
}

.sidebar-upgrade-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--color-cta);
  color: var(--color-ink);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.sidebar-upgrade-btn:hover {
  background: #f59e0b;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
}

/* ============================================================================
   Mobile Upgrade Bar (compact, top of main content, mobile only)
   ============================================================================ */
.mobile-upgrade-bar {
  display: none; /* shown via JS for free users */
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: var(--space-md);
}

.mobile-upgrade-text {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.3;
}

.mobile-upgrade-text strong {
  color: #fff;
}

.mobile-upgrade-btn {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-cta);
  color: var(--color-ink);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(251, 191, 36, 0.25);
}

.mobile-upgrade-btn:hover {
  background: #f59e0b;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
/* Desktop: hide mobile bar, show sidebar upgrade */
@media (min-width: 769px) {
  .mobile-upgrade-bar {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  /* Hide sidebar upgrade on mobile (use mobile bar instead) */
  .sidebar-upgrade {
    display: none !important;
  }

  .main-content {
    padding-top: 56px;
  }

  .flex-between {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  h1 {
    font-size: 1.75rem;
  }

  .pricing-card.featured {
    transform: scale(1);
  }

  .comparison-table {
    font-size: 0.875rem;
  }

  .nav-links {
    gap: var(--space-md);
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }
}
