/* ==========================================================================
   SmartPrint Studio - Global Stylesheet & Millimeter-Accurate Print Engine
   Path: public/css/style.css
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-workspace: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
  --shadow-paper: 0 12px 32px rgba(15, 23, 42, 0.22);
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans Arabic', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* ==========================================================================
   Navigation Header & Language Bar
   ========================================================================== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--secondary);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.brand-badge {
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-link:hover,
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lang-select {
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
}

.btn-accent:hover {
  background: #059669;
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-body);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ==========================================================================
   Container, Hero & Tool Cards (Home Page)
   ========================================================================== */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  width: 100%;
}

.hero-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  color: #93c5fd;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.25;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: #cbd5e1;
  max-width: 780px;
  margin: 0 auto 1.75rem;
}

.hero-features {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.hero-feature-item {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.tool-card-badge {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.tool-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.tool-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

.tool-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.tool-perks {
  list-style: none;
  margin-bottom: 1.25rem;
  font-size: 0.84rem;
  color: var(--secondary);
}

.tool-perks li {
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ==========================================================================
   Studio Workspace Layout (Sidebar Controls + Live Paper Canvas)
   ========================================================================== */
.studio-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

.studio-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.sidebar-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-preview-area {
  background: var(--bg-workspace);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 750px;
}

.preview-toolbar {
  width: 100%;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

/* Live A4 Paper Sheet on Screen */
.a4-sheet-preview {
  background: #ffffff;
  width: 210mm;
  min-height: 280mm;
  box-shadow: var(--shadow-paper);
  position: relative;
  transition: all 0.2s ease;
  transform-origin: top center;
  overflow: hidden;
}

@media (max-width: 900px) {
  .a4-sheet-preview {
    width: 100%;
    min-height: auto;
  }
}

/* Sticker Grid Cell & "Used Sticker Saver" Feature */
.sticker-grid {
  display: grid;
  width: 100%;
  height: 100%;
}

.sticker-cell {
  border: 1px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: #ffffff;
  transition: background 0.15s ease;
  text-align: center;
}

.sticker-cell:hover {
  border-color: var(--primary);
  background: #f8fafc;
}

.sticker-cell.skipped-slot {
  background: repeating-linear-gradient(
    45deg,
    #f1f5f9,
    #f1f5f9 8px,
    #e2e8f0 8px,
    #e2e8f0 16px
  );
  opacity: 0.55;
}

.sticker-cell.skipped-slot::after {
  content: attr(data-skip-label);
  position: absolute;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   Google AdSense Smart Containers (Visible on Screen, Hidden on Print)
   ========================================================================== */
.ad-container {
  width: 100%;
  max-width: 100%;
  margin: 1.25rem auto;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
  min-height: 95px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   SEO Content & Guide Section (Essential for AdSense Approval)
   ========================================================================== */
.seo-article-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  margin-top: 2.5rem;
  box-shadow: var(--shadow-sm);
}

.seo-article-box h2 {
  font-size: 1.5rem;
  color: var(--secondary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

.seo-article-box h3 {
  font-size: 1.15rem;
  color: var(--secondary);
  margin: 1.25rem 0 0.5rem;
}

.seo-article-box p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.faq-item {
  background: var(--bg-body);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.faq-item h4 {
  color: var(--secondary);
  margin-bottom: 0.4rem;
  font-size: 0.98rem;
}

/* ==========================================================================
   Footer & Toast Notification
   ========================================================================== */
.site-footer {
  background: var(--secondary);
  color: #cbd5e1;
  margin-top: auto;
  padding: 2.5rem 1.25rem 1.5rem;
}

.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1.5rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: #cbd5e1;
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: #ffffff;
}

.footer-copy {
  max-width: 1360px;
  margin: 1rem auto 0;
  font-size: 0.85rem;
  text-align: center;
  color: #94a3b8;
}

.toast-msg {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  background: var(--secondary);
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   PRINT MEDIA ENGINE (@media print) - Locks Output to Exactly 1 Page!
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 0mm !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html,
  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .site-header,
  .site-footer,
  .studio-sidebar,
  .preview-toolbar,
  .ad-container,
  .seo-article-box,
  .no-print,
  .toast-msg {
    display: none !important;
  }

  .container,
  .studio-layout,
  .studio-preview-area {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: #ffffff !important;
    width: 100% !important;
    min-height: 0 !important;
  }

  .a4-sheet-preview {
    box-shadow: none !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 210mm !important;
    min-height: 0 !important;
    max-height: 274mm !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .a4-sheet-preview svg {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    display: block !important;
  }

  .sticker-cell {
    border-color: transparent !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .sticker-cell.show-cut-lines {
    border: 0.5pt dashed #cbd5e1 !important;
  }

  .sticker-cell.skipped-slot {
    background: transparent !important;
    opacity: 0 !important;
  }

  .sticker-cell.skipped-slot * {
    visibility: hidden !important;
  }

  .sticker-cell.skipped-slot::after {
    display: none !important;
  }
}