:root {
  /* Light Theme Defaults */
  --bg-color: #ffffff;
  --sidebar-bg: #ffffff;
  --text-primary: #1f1f1f;
  --text-secondary: #444746;
  --border-color: #e0e3e1;
  --hover-bg: #dfe4ea;
  --accent-blue: #2563eb;
  --accent-green: #14ae5c;
  --font-main: 'Outfit', sans-serif;
  
  --card-bg: #ffffff;
  --card-header-bg: #fafafa;
  --header-bg: #ffffff;
  --active-nav-bg: #c2e7ff;
  --active-nav-text: #001d35;
  
  --price-color: #b91c1c;
  --star-color: #f59e0b;
  --tag-bg: #e0e7ff;
  --tag-text: #3730a3;
  --review-bg: #f9f9f9;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-color: #121212;
  --sidebar-bg: #18181b;
  --text-primary: #e2e2e2;
  --text-secondary: #9ca3af;
  --border-color: #2e2e2e;
  --hover-bg: #2d2d2d;
  --accent-blue: #60a5fa;
  
  --card-bg: #1e1e1e;
  --card-header-bg: #252525;
  --header-bg: #18181b;
  
  --active-nav-bg: rgba(96, 165, 250, 0.15);
  --active-nav-text: #bfdbfe;
  
  --price-color: #f87171;
  --review-bg: #252525;
  --tag-bg: #312e81;
  --tag-text: #c7d2fe;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    /* This prevents the "rubber-band" effect on iPad that breaks sticky headers */
    width: 100%;
    margin: 0;
    padding: 0;
}

* { 
  box-sizing: border-box; 
  -webkit-tap-highlight-color: transparent; 
}

body { 
  margin: 0; 
  font-family: var(--font-main); 
  background: var(--bg-color); 
  color: var(--text-primary); 
  height: 100vh; 
  display: flex; 
  overflow: hidden; 
  transition: background 0.3s, color 0.3s; 
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c7c5; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #8e918f; }

/* --- LAYOUT COMPONENTS --- */

/* Sidebar */
#sidebar { 
  width: 300px; 
  background: var(--sidebar-bg); 
  display: flex; 
  flex-direction: column; 
  flex-shrink: 0; 
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  z-index: 50; 
  overflow: hidden;
  white-space: nowrap;
  border-right: 1px solid var(--border-color);
}

body.sidebar-collapsed #sidebar { 
  width: 0; 
  border: none; 
}

/* Mobile Overlay */
#mobile-overlay { 
  position: fixed; 
  top: 0; left: 0; right: 0; bottom: 0; 
  background: rgba(0,0,0,0.4); 
  z-index: 40; 
  display: none; 
}

/* Fix: Only show overlay on mobile devices */
@media (max-width: 1024px) {
  #sidebar { 
    position: fixed; 
    height: 100%; 
    left: 0; top: 0; 
    transform: translateX(-100%); 
    width: 280px; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  }
  
  body.mobile-sidebar-open #sidebar { 
    transform: translateX(0); 
  }
  
  /* Overlay logic moved inside media query to prevent desktop appearance */
  body.mobile-sidebar-open #mobile-overlay { 
    display: block; 
  }
}

.sidebar-header { 
  padding-left: 20px; 
  display: flex; 
  align-items: center; 
  height: 64px; 
  border-bottom: 1px solid var(--border-color); 
}

.app-title { 
  font-weight: 700; 
  font-size: 22px; 
  color: var(--accent-blue); 
}

.category-list { 
  flex: 1; 
  overflow-y: auto; 
  padding: 12px; 
}

.nav-item { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 12px 16px; 
  border-radius: 50px; 
  cursor: pointer; 
  font-size: 14px; 
  margin-bottom: 4px; 
  color: var(--text-primary); 
  transition: 0.2s; 
}

.nav-item:hover { 
  background: var(--hover-bg); 
}

.nav-item.active { 
  background: var(--active-nav-bg); 
  color: var(--active-nav-text); 
  font-weight: 600; 
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0; /* CRITICAL: Prevents flex children from pushing width */
    overflow-x: hidden;
}

header { 
  height: 64px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 0 20px; 
  position: sticky; 
  top: 0; 
  background: var(--header-bg); 
  z-index: 10; 
  border-bottom: 1px solid transparent; 
  backdrop-filter: blur(8px); 
  border-bottom: 1px solid var(--border-color);
}

.btn-icon { 
  background: none; 
  border: none; 
  cursor: pointer; 
  padding: 8px; 
  border-radius: 50%; /* Default circular */
  color: var(--text-secondary); 
  display: flex; 
  align-items: center; 
  justify-content: center;
  transition: background 0.2s, border-radius 0.2s; /* Smooth transition */
}

/* Hover State: Square with rounded corners */
.btn-icon:hover { 
  background: var(--hover-bg); 
  border-radius: 8px; 
}

/* Header Title Logic */
.header-page-title {
  font-size: 18px; 
  font-weight: 700; 
  color: var(--accent-blue);
  margin-left: 8px;
  display: none; /* Hidden by default on desktop when sidebar is open */
}

/* Show when sidebar is collapsed */
body.sidebar-collapsed .header-page-title { 
  display: block; 
}

/* Show always on mobile */
@media (max-width: 1024px) {
  .header-page-title { 
    display: block; 
  }
}

/* Top Right Logo */
.top-logo {
  font-family: var(--font-main);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.5px;
  margin-left: 8px;
  cursor: pointer;
}

.logo-accent { 
  color: var(--accent-blue); 
}

#content-scroll { 
  flex: 1; 
  overflow-y: auto; 
  padding-bottom: 80px; 
}

.container {
    width: 100%;
    max-width: 100%; /* Ensures it never goes wider than the screen */
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box; /* Includes padding in the width calculation */
}

/* Headers */
.page-header { margin-bottom: 32px; }

.badge { 
  display: inline-block; 
  background: var(--active-nav-bg); 
  color: var(--active-nav-text); 
  padding: 4px 12px; 
  border-radius: 50px; 
  font-size: 12px; 
  font-weight: 600; 
  text-transform: uppercase; 
  margin-bottom: 12px; 
}

.main-headline { 
  font-size: 32px; 
  font-weight: 500; 
  margin: 0; 
  line-height: 1.2; 
}

.sub-headline { 
  color: var(--text-secondary); 
  margin-top: 8px; 
  font-size: 16px; 
}

.disclaimer { 
  font-size: 11px; 
  color: var(--text-secondary); 
  margin-top: 10px; 
  opacity: 0.7; 
}

/* --- PRODUCT GRID --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.08);
  border-color: var(--accent-blue);
}

.img-container {
  width: 100%;
  height: 200px;
  background: #fff; /* Always white for product visibility */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.product-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.prod-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.card-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.prod-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px 0;
  line-height: 1.4;
  color: var(--text-primary);
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.stars { 
  color: var(--star-color); 
  font-size: 14px; 
}

.review-box {
  background: var(--review-bg);
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent-blue);
}

.review-label {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 11px;
  text-transform: uppercase;
}

.buy-btn {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-blue);
  color: white;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.2s;
}

.buy-btn:hover { 
  opacity: 0.9; 
  box-shadow: 0 4px 12px rgba(11, 87, 208, 0.3); 
}

.buy-btn.download-btn { 
  background: var(--accent-green); 
}

.buy-btn.download-btn:hover { 
  box-shadow: 0 4px 12px rgba(20, 174, 92, 0.3); 
}

/* Contact Section */
.contact-section {
  grid-column: 1 / -1;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  margin-top: 24px;
}

.contact-title { 
  font-size: 20px; 
  font-weight: 600; 
  margin-bottom: 8px; 
}

.contact-text { 
  color: var(--text-secondary); 
  margin-bottom: 20px; 
  font-size: 14px; 
}

.contact-btn {
  display: inline-block;
  background: var(--text-primary);
  color: var(--bg-color);
  padding: 10px 24px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.contact-btn:hover { 
  opacity: 0.8; 
}

/* --- MODAL STYLES --- */
.modal-overlay {
  position: fixed; 
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay.open { 
  display: flex; 
  opacity: 1; 
}

.modal-box {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  position: relative;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.open .modal-box { 
  transform: translateY(0); 
}

.modal-close {
  position: absolute; 
  top: 16px; 
  right: 16px;
  background: none; 
  border: none; 
  cursor: pointer;
  color: var(--text-secondary);
}

.form-group { 
  margin-bottom: 20px; 
}

.form-label { 
  display: block; 
  margin-bottom: 8px; 
  font-weight: 500; 
  font-size: 14px; 
}

.form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
}

.form-input:focus { 
  outline: 2px solid var(--accent-blue); 
  border-color: transparent; 
}

.form-note { 
  font-size: 12px; 
  color: var(--text-secondary); 
  margin-bottom: 24px; 
}

.submit-btn {
  width: 100%;
  background: var(--accent-blue);
  color: white;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
}

.submit-btn:hover { 
  opacity: 0.9; 
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .main-headline { font-size: 24px; }
  .img-container { height: 180px; }
  .top-logo { font-size: 16px; }
  .modal-box { padding: 24px; }
}

/* --- EXCEL-STYLE TAB BAR --- */
.tab-bar-wrapper {
  position: sticky;
  top: 64px; /* Matches your 64px header */
  z-index: 9; 
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.tab-bar-wrapper::before, .tab-bar-wrapper::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40px;
  pointer-events: none; z-index: 10; opacity: 0; transition: opacity 0.3s ease;
}
.tab-bar-wrapper::before { left: 0; background: linear-gradient(to right, var(--bg-color) 0%, transparent 100%); }
.tab-bar-wrapper::after { right: 0; background: linear-gradient(to left, var(--bg-color) 0%, transparent 100%); }
.tab-bar-wrapper.can-scroll-left::before { opacity: 1; }
.tab-bar-wrapper.can-scroll-right::after { opacity: 1; }

.excel-tab-bar { display: flex; overflow-x: auto; scrollbar-width: none; 
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Enables smooth finger scrolling on iPad */
    flex-wrap: nowrap; /* Ensures tabs stay in one line */
    width: 100%;
}
.excel-tab-bar::-webkit-scrollbar { display: none; }

.tab-link {
  padding: 14px 20px; white-space: nowrap; color: var(--text-secondary);
  font-size: 14px; font-weight: 600; border-bottom: 3px solid transparent;
  cursor: pointer; transition: all 0.2s ease; display: flex;
  align-items: center; gap: 6px; background: transparent; border-top: none;
  border-left: none; border-right: none; font-family: var(--font-main);
  text-decoration: none;
}
.tab-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.tab-link.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); background: rgba(37, 99, 235, 0.05); }

/* --- QUICK READS DROPDOWN --- */
.tab-dropdown { position: relative; display: inline-block; }
.tab-dropdown-menu {
  display: none; position: fixed; transform: translateX(-50%);
  background: var(--card-bg); min-width: 250px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color); border-radius: 12px; z-index: 1000;
  flex-direction: column; overflow: hidden;
}
.tab-dropdown-menu.show { display: flex; animation: fadeIn 0.2s ease-in-out; }
.tab-dropdown-menu a { padding: 12px 16px; color: var(--text-secondary); font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--border-color); transition: 0.2s; text-decoration: none; }
.tab-dropdown-menu a:hover { background: var(--active-nav-bg); color: var(--text-primary); }
.tab-dropdown-menu a:last-child { border-bottom: none; }
.dropdown-toggle.open svg { transform: rotate(180deg); }
.dropdown-toggle svg { transition: transform 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }


/* Form */

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea {
    resize: vertical; /* Restricts resizing to vertical only */
    min-height: 80px; /* Optional: Sets a reasonable minimum height */
    max-height: 300px; /* Optional: Prevents it from getting too tall */
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.1);
}

/* Ensure placeholder text adapts to themes */
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}