/* style.css - FINAL CLEANED & MERGED VERSION */

:root {
  --primary: #007aff;
  --primary-dark: #0056b3;
  --secondary: #5856d6;
  --accent: #ff2d55;
  --background: #f5f5f7;
  --text-main: #1d1d1f;
  --text-muted: #86868b;
  --card-bg: #ffffff;
  --success: #34c759;
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 16px;
  --gradient-hero: linear-gradient(135deg, #007aff 0%, #00c7be 100%);
}

/* --- 1. RESET & BASE --- */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  background-color: var(--background);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

/* --- 2. COMPONENTS & UTILITIES --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Buttons */
.btn,
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  text-align: center;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 122, 255, 0.3);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-outline {
  background: transparent;
  border: 2px solid #ddd;
  color: #333;
  box-shadow: none;
}
.btn-outline:hover {
  background: #f5f5f7;
  transform: translateY(-2px);
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  margin-bottom: 25px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}
.card:hover {
  transform: translateY(-2px);
}

/* Form Elements */
input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  margin-bottom: 15px;
}
input:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
}

/* Tables - Horizontal Scroll Fix */
table {
  width: 100%;
  border-collapse: collapse;
}
div[style*="overflow-x:auto"] {
  -webkit-overflow-scrolling: touch;
  width: 100%;
  display: block;
  margin-bottom: 15px;
}
th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

/* --- 3. LANDING PAGE STYLES --- */
.layout-landing {
  background: white;
}
.landing-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid #eee;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}
.brand {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  margin: 0;
}

.landing-nav {
  display: flex;
  gap: 30px;
}
.landing-nav a {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 500;
  font-size: 15px;
  transition: color 0.2s;
}
.landing-nav a:hover,
.landing-nav a.active-link {
  color: var(--primary);
  font-weight: 700;
}
.landing-auth {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Hero */
.hero-section {
  background: var(--gradient-hero);
  color: white;
  padding: 100px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 50px;
}
.hero-title {
  font-size: 56px;
  font-weight: 800;
  margin-bottom: 20px;
  letter-spacing: -1px;
  line-height: 1.1;
}
.hero-subtitle {
  font-size: 22px;
  opacity: 0.9;
  max-width: 700px;
  margin: 0 auto 40px;
  font-weight: 400;
}
.hero-badges {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
  opacity: 0.8;
  font-size: 14px;
}

/* Marketing Grids */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  margin: 50px 0;
}
.tier-card {
  text-align: center;
  position: relative;
  height: 100%;
  border: 1px solid #eee;
}
.tier-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}
.tier-price {
  font-size: 42px;
  font-weight: 800;
  margin: 15px 0;
  color: var(--text-main);
}
.tier-features {
  list-style: none;
  padding: 0;
  margin: 20px 0;
}
.tier-features li {
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f7;
  font-size: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tier-features ion-icon {
  color: var(--success);
  font-size: 18px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.review-card {
  background: #fff;
  padding: 25px;
  border-radius: 16px;
  border: 1px solid #eee;
}
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  margin-top: 50px;
  text-align: left;
}
.contact-section {
  background: #1c1c1e;
  color: white;
  padding: 80px 0;
  margin-top: 80px;
  text-align: center;
}

.landing-footer {
  background: #f9f9f9;
  padding: 40px 0;
  text-align: center;
  color: #888;
  margin-top: 60px;
  font-size: 13px;
}

/* FAQ Styles */
.faq-item {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid #eee;
}
.faq-question {
  padding: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-answer {
  padding: 0 20px 20px;
  color: #666;
  display: none;
  border-top: 1px solid #f5f5f7;
}
.faq-item.active .faq-answer {
  display: block;
}
.faq-item.active .faq-question {
  color: var(--primary);
}

/* --- 4. APP DASHBOARD STYLES --- */
.layout-app .app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 30px 20px;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px;
  max-width: 100%;
}

.nav-label {
  font-size: 11px;
  font-weight: 800;
  color: #aaa;
  margin: 25px 0 10px 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: 0.2s;
  font-weight: 500;
}
.nav-link:hover {
  background: rgba(0, 122, 255, 0.05);
  color: var(--primary);
}
.nav-link.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.nav-link ion-icon {
  font-size: 20px;
}

/* Cart & Catalog Specifics */
.grid-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.qty-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f5f7;
  border-radius: 8px;
  padding: 4px;
  margin-top: 10px;
}
.qty-btn {
  width: 30px;
  height: 30px;
  background: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-val {
  font-weight: 700;
  width: 30px;
  text-align: center;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid #eee;
  padding: 15px 0;
  background: white;
}
.cart-img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

/* Hidden by default on Desktop */
.mobile-header,
.sidebar-overlay,
.close-sidebar-btn,
.mobile-menu-btn,
.landing-mobile-menu,
.mobile-tabs {
  display: none;
}

/* --- 5. MOBILE RESPONSIVENESS FIX (Max 1024px) --- */
@media (max-width: 1024px) {
  /* A. DASHBOARD LAYOUT */
  .layout-app .app-shell {
    flex-direction: column;
  }

  /* Mobile Header */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 20px;
    background: white;
    border-bottom: 1px solid #eee;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 900;
  }

  /* Sidebar Drawer Logic */
  .sidebar {
    transform: translateX(-100%); /* Hide off-screen */
    width: 280px;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 2000;
  }
  .sidebar.active {
    transform: translateX(0); /* Slide In */
  }

  /* Content Adjustment */
  .main-content {
    margin-left: 0;
    margin-top: var(--header-height);
    padding: 20px;
    width: 100%;
  }

  /* Overlay & Buttons */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
    backdrop-filter: blur(4px);
  }
  .sidebar-overlay.active {
    display: block;
  }
  .close-sidebar-btn {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    color: #555;
    cursor: pointer;
  }

  /* B. LANDING PAGE MOBILE */
  .landing-nav {
    display: none;
  } /* Hide Desktop Nav */
  .mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
  }

  .landing-mobile-menu {
    display: none;
    background: white;
    padding: 20px;
    border-bottom: 1px solid #eee;
    flex-direction: column;
    gap: 15px;
  }
  .landing-mobile-menu.active {
    display: flex;
  }
  .landing-mobile-menu a {
    font-weight: 600;
    color: #333;
    text-decoration: none;
    padding: 10px 0;
    border-bottom: 1px solid #f9f9f9;
  }

  .hero-title {
    font-size: 36px;
  }
  .hero-subtitle {
    font-size: 18px;
    padding: 0 10px;
  }
  .hero-badges {
    flex-direction: column;
    gap: 8px;
  }

  /* Force buttons to stack */
  .hero-section div[style*="display: flex"] {
    display: block !important;
  }
  .hero-section .btn {
    width: 100%;
    margin-bottom: 10px;
  }

  /* C. GRID FIXES */
  .grid-books,
  .tier-grid,
  .review-grid,
  .contact-grid {
    grid-template-columns: 1fr !important;
  }
}

/* --- MODAL / POPUP STYLES (Add to bottom of style.css) --- */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Dark transparent background */
  z-index: 3000; /* Sit on top of everything */
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px); /* Blur effect */
}

/* When JS sets display:flex, this centers it */
.modal-overlay[style*="display: flex"] {
  display: flex !important;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 550px; /* Limits width on desktop */
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: slideUp 0.3s ease;
  max-height: 90vh; /* Prevents being too tall */
  overflow-y: auto; /* Scroll if too tall */
}

/* Animation for smooth opening */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- FLOATING CART COMPONENT --- */

/* 1. The Floating Button (FAB) */
.floating-cart-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 10px 25px rgba(0, 122, 255, 0.4);
  cursor: pointer;
  z-index: 9990; /* High z-index */
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.floating-cart-btn:hover {
  transform: scale(1.1);
}
.floating-cart-btn:active {
  transform: scale(0.95);
}

/* Badge for Count */
.cart-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* 2. The Slide-In Drawer (Mini Cart) */
.cart-drawer {
  position: fixed;
  top: 0;
  right: -400px; /* Hidden by default */
  width: 350px;
  height: 100vh;
  background: white;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
  z-index: 10000; /* Highest */
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}
.cart-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9f9f9;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.drawer-footer {
  padding: 20px;
  border-top: 1px solid #eee;
  background: white;
}

/* Mini Items inside Drawer */
.mini-item {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 1px solid #f5f5f7;
  padding-bottom: 15px;
}
.mini-img {
  width: 50px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
}
.mini-details {
  flex: 1;
  font-size: 14px;
}
.mini-price {
  font-weight: bold;
  color: var(--primary);
  margin-top: 4px;
}

/* Backdrop */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9995;
  display: none;
  backdrop-filter: blur(2px);
}
.drawer-backdrop.active {
  display: block;
}

/* Mobile Adjustment */
@media (max-width: 600px) {
  .cart-drawer {
    width: 100%;
    right: -100%;
  }
  .floating-cart-btn {
    bottom: 20px;
    right: 20px;
  }
}

/* --- ROBUST CART PAGE RESPONSIVENESS --- */

/* 1. Desktop Layout (Standard Grid) */
.cart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* 66% Items, 33% Summary */
  gap: 30px;
  align-items: start;
}

/* 2. Mobile Layout (Force Stack) */
@media (max-width: 900px) {
  .cart-grid {
    display: flex !important;
    flex-direction: column; /* Stack vertically */
  }

  /* Force panels to take full width */
  .cart-items-panel,
  .cart-summary-panel {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Ensure Items appear BEFORE Summary */
  .cart-items-panel {
    order: 1;
  }
  .cart-summary-panel {
    order: 2;
    margin-top: 20px;
  }

  /* Unstick the summary on mobile so it scrolls naturally */
  .cart-summary {
    position: static !important;
  }
}

/* Summary Card Styling */
.cart-summary {
  background: white;
  padding: 25px;
  border-radius: 16px;
  border: 1px solid #eee;
  position: sticky;
  top: 90px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  color: #555;
}

.summary-total {
  border-top: 2px solid #f5f5f7;
  padding-top: 15px;
  margin-top: 15px;
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 20px;
  color: var(--text-main);
}

/* --- DASHBOARD REFINED STYLES --- */

/* 1. KPI CARDS (Desktop: 4 columns, Mobile: 2 columns) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 120px; /* Prevents squishing */
}
.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  margin: 8px 0;
}
.stat-trend {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Colors */
.border-blue {
  border-left: 4px solid #007aff;
}
.border-green {
  border-left: 4px solid #34c759;
}
.border-orange {
  border-left: 4px solid #ff9500;
}
.border-purple {
  border-left: 4px solid #af52de;
}
.text-up {
  color: #34c759;
}
.text-neutral {
  color: #888;
}

/* 2. MAIN LAYOUT (Left Chart, Right Sidebar) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* 66% - 33% split */
  gap: 25px;
  align-items: start;
}
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}
.badge-blue {
  background: #eef7ff;
  color: #007aff;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 11px;
}

/* 3. MOBILE RESPONSIVENESS FIXES */
@media (max-width: 1024px) {
  /* Make KPIs 2x2 on Mobile (Much better than 1x4) */
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }

  /* Stack Main Content */
  .dashboard-grid {
    display: flex;
    flex-direction: column;
  }

  .main-column,
  .side-column {
    width: 100%;
  }

  /* Adjust Font Sizes for Mobile */
  .stat-value {
    font-size: 22px;
  }
}

/* --- FORM FIXES FOR RADIO & CHECKBOXES --- */

/* 1. Reset width for Checkboxes & Radios so they aren't huge */
input[type="radio"],
input[type="checkbox"] {
  width: auto !important; /* Stop them from stretching */
  margin-right: 10px;
  cursor: pointer;
  accent-color: var(--primary); /* Makes them blue */
  transform: scale(1.2); /* Make them slightly easier to click */
}

/* 2. Container for aligned options */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

/* 3. Individual Option Row */
.option-row {
  display: flex;
  align-items: center; /* Aligns dot/box with text vertically */
  font-size: 15px;
  color: #444;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.option-row:hover {
  background: #f5f5f7;
}

/* 4. Grid for Checkboxes (2 columns on desktop) */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
