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

:root {
  /* Colors */
  --bg-primary: #07080d;
  --bg-secondary: #0e111a;
  --bg-tertiary: #161a29;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;
  
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 255, 255, 0.15);

  /* Glassmorphism */
  --glass-bg: rgba(14, 17, 26, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-blur: blur(12px);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

  --sidebar-bg: rgba(14, 17, 26, 0.9);
  --topbar-bg: rgba(7, 8, 13, 0.7);
  --hover-bg: rgba(255, 255, 255, 0.05);

  /* Accents */
  --accent-admin: #8b5cf6;     /* Purple */
  --accent-staff: #ef4444;     /* Coral Red */
  --accent-merchant: #10b981;  /* Emerald */
  --accent-client: #3b82f6;    /* Cobalt Blue */
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  /* Light Mode Colors */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dark: #334155;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 0, 0, 0.15);

  /* Light Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.05);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.03);

  --sidebar-bg: rgba(255, 255, 255, 0.9);
  --topbar-bg: rgba(248, 250, 252, 0.7);
  --hover-bg: rgba(0, 0, 0, 0.05);
}

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

html {
  font-size: 14px; /* Reduces all rem-based text by ~12.5% */
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 10% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 40%);
}

@media (min-width: 1025px) {
  body {
    zoom: 0.65; /* Global scale down requested by user */
  }
  .app-container, .main-content, .sidebar {
    height: calc(100vh / 0.65) !important;
    min-height: calc(100vh / 0.65) !important;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* Layout Shell */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #fff);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: #07080d;
}

.sidebar-brand {
  font-size: 1.15rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.menu-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dark);
  font-weight: 700;
  padding: 10px 12px 6px;
  letter-spacing: 0.05em;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.menu-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-dark);
  transition: color var(--transition);
}

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

.menu-item:hover svg { color: var(--text-main); }

.menu-item.active {
  background: var(--hover-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}

.menu-item.active svg {
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(7, 8, 13, 0.3);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  transition: background var(--transition);
}

.profile-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}

.profile-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.profile-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.profile-role {
  font-size: 0.65rem;
  color: var(--text-dark);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Main Layout */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top Bar */
.top-bar {
  height: 60px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--topbar-bg);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--border-color);
}

.page-title {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.demo-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* Content Frame */
.content-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Glass Panels */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-glow);
  padding: 20px;
  margin-bottom: 20px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.85rem;
  width: 100%;
  transition: all var(--transition);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.05);
}

/* Grid Systems */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-box {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th, .custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.custom-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.01);
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.15);
}
.btn-danger:hover {
  background: var(--error);
  color: #fff;
}

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-paid { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.15); }
.badge-unpaid { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.15); }
.badge-draft { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); border: 1px solid var(--border-color); }

/* Authentication Overlay */
.auth-body {
  align-items: center;
  justify-content: center;
}

.auth-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 40px;
}

/* Canvas Draw */
.canvas-container {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  height: 200px;
  cursor: crosshair;
}

/* Invoice Paper preview */
.paper-invoice {
  background: #ffffff;
  color: #1f2937;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 25px rgba(0,0,0,0.15);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #374151;
}

.paper-invoice h2, .paper-invoice h3, .paper-invoice h4 {
  color: #111827;
}

.invoice-preview-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

@media (max-width: 1024px) {
  .invoice-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Public Website Landing Page Styles */
.website-landing {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.landing-nav {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 40px;
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  text-decoration: none;
}

.landing-logo-badge {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-admin), var(--accent-client));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 800;
}

.landing-hero {
  text-align: center;
  padding: 60px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.hero-pill {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.landing-hero h1 {
  font-size: 3rem;
  line-height: 1.15;
  background: linear-gradient(to right, #fff, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  max-width: 800px;
}

.landing-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 600px;
}

.product-showcase {
  margin-top: 40px;
  margin-bottom: 100px;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.product-card {
  height: 360px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  padding: 24px;
}

.card-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.card-header-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.card-header-icon svg {
  width: 22px;
  height: 22px;
}

.product-card h3 {
  font-size: 1.25rem;
  margin-bottom: 10px;
}

.product-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  flex: 1;
  margin-bottom: 20px;
}

.features-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.feature-bullet {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.feature-bullet svg {
  width: 12px;
  height: 12px;
}


/* --- Custom Animations --- */
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- Mobile Menu Button & Overlay --- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* --- Live Preview Grids (Adjustable Split Pane) --- */
.quotation-preview-grid, .invoice-preview-grid {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.quotation-preview-grid > .glass-card, 
.invoice-preview-grid > .glass-card {
    flex: 0 0 auto;
    width: 45%;
    min-width: 400px;
    max-width: 80%;
    resize: horizontal;
    overflow: auto; /* Required for resize handle */
}

.quotation-preview-grid > div:last-child, 
.invoice-preview-grid > div:last-child {
    flex: 1 1 0;
    min-width: 300px;
}

.preview-wrapper {
    width: 516px;
    height: 730px; /* 1123 * 0.65 */
    overflow: hidden;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    background: #fff;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1200px) {
    .quotation-preview-grid, .invoice-preview-grid {
        flex-direction: column !important;
        gap: 20px;
    }
    .quotation-preview-grid > .glass-card, 
    .invoice-preview-grid > .glass-card,
    .quotation-preview-grid > div:last-child, 
    .invoice-preview-grid > div:last-child {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex: none !important;
        resize: none !important;
    }
    
    /* Scale the live preview container slightly down on medium screens */
    .preview-wrapper {
        transform: scale(0.8);
        transform-origin: top center;
        margin: 0 auto -146px auto; /* Compacting height after scaling 730 * 0.2 = 146 */
    }
}

@media (max-width: 1024px) {
  body {
    zoom: 1;
  }
  .app-container {
    flex-direction: column;
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Hidden off canvas */
    width: 260px;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  
  body.sidebar-open .sidebar {
    left: 0;
  }
  body.sidebar-open .mobile-sidebar-overlay {
    display: block;
    opacity: 1;
  }

  .sidebar-menu {
    flex-direction: column;
    flex-wrap: nowrap;
    max-height: none;
  }
  .menu-section {
    width: auto;
  }
  .menu-item {
    flex: none;
    min-width: 0;
  }
  
  .main-content {
    padding: 10px;
    width: 100%;
  }
  .stats-grid {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .stat-box {
    min-width: 130px;
    flex: 1;
    padding: 12px;
  }
  .stat-box span {
    font-size: 0.7rem !important;
  }
  .stat-num {
    font-size: 1.1rem !important;
  }
}

@media (max-width: 768px) {
  .auth-wrapper {
    width: 95% !important;
    margin: 10px auto;
    padding: 20px !important;
  }
  
  /* Tables horizontally swipeable */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
  }
  
  .custom-table {
    white-space: nowrap;
    min-width: 600px; /* Force minimum width to trigger scroll on small screens */
  }
  
  /* Scale live preview heavily on mobile */
  .preview-wrapper {
      transform: scale(0.65);
      margin: 0 auto -255px auto; /* 730 * 0.35 = 255.5 */
  }
  
  /* Stack line items for mobile */
  .item-row {
      display: flex !important;
      flex-direction: column !important;
      border: 1px solid var(--border-color);
      border-radius: 8px;
      padding: 10px;
      margin-bottom: 10px;
      background: var(--bg-tertiary);
  }
  .item-row > div {
      width: 100% !important;
      margin-bottom: 10px;
  }
  .item-row > div:last-child {
      margin-bottom: 0;
  }
  
  /* Adjust Dashboard Tabs for Swipe */
  .dash-tabs {
      flex-wrap: nowrap;
      -webkit-overflow-scrolling: touch;
  }
}

