/* =====================================================================
   CodeCrane.co.uk — Design System
   Corporate, clean, responsive. Light/Dark via [data-theme] + CSS vars.
   ===================================================================== */

:root {
  --font-main: 'Kanit', 'Segoe UI', Arial, sans-serif;

  --brand-600: #1656d1;
  --brand-500: #2f6fed;
  --brand-400: #5b8ff5;
  --brand-100: #e8f0fe;
  --accent-500: #f5a623;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(20, 30, 60, .08);
  --shadow-md: 0 6px 20px rgba(20, 30, 60, .10);
  --shadow-lg: 0 16px 40px rgba(20, 30, 60, .16);
  --transition: 180ms ease;
  --header-h: 72px;
}

[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-elevated: #ffffff;
  --bg-muted: #eef1f8;
  --text: #101828;
  --text-muted: #5b6472;
  --border: #e2e6ee;
  --nav-bg: #ffffff;
  --footer-bg: #10182a;
  --footer-text: #c9d1e0;
}

[data-theme="dark"] {
  --bg: #0c1220;
  --bg-elevated: #141c2e;
  --bg-muted: #1a2338;
  --text: #eef1f8;
  --text-muted: #a2acc0;
  --border: #253052;
  --nav-bg: #101828;
  --footer-bg: #070b14;
  --footer-text: #98a2b8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

img { max-width: 100%; display: block; }
a { color: var(--brand-500); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.85rem; }
h3 { font-size: 1.4rem; }
p { margin: 0 0 1em; color: var(--text-muted); }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--brand-600); color: #fff;
  padding: 10px 16px; z-index: 1000;
}
.skip-link:focus { left: 10px; top: 10px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-main); font-weight: 500; font-size: .95rem;
  padding: 12px 22px; border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); text-decoration: none; }
.btn-accent { background: var(--accent-500); color: #29210a; }
.btn-accent:hover { filter: brightness(.95); text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-muted); text-decoration: none; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------------- Header / Nav ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 500;
  background: var(--nav-bg); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(6px);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 34px; width: auto; }
.brand-name { font-weight: 700; font-size: 1.3rem; color: var(--text); letter-spacing: .5px; }
.brand-accent { color: var(--brand-600); }

.nav-toggle { display: none; background: none; border: none; font-size: 1.4rem; color: var(--text); cursor: pointer; }

.site-nav ul { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.site-nav > ul > li { position: relative; }
.site-nav a {
  display: block; padding: 10px 14px; color: var(--text); font-weight: 500; border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--bg-muted); text-decoration: none; }
.has-dropdown .dropdown {
  display: none; position: absolute; top: 100%; left: 0; min-width: 240px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 8px; flex-direction: column;
}
.has-dropdown:hover .dropdown { display: flex; }
.dropdown li a { white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; color: var(--text); font-size: 1.05rem;
  background: transparent; border: none; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-muted); text-decoration: none; }
.theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: inline; }
.cart-count {
  position: absolute; top: 2px; right: 2px; background: var(--accent-500); color: #29210a;
  font-size: .65rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ---------------- Flash messages ---------------- */
.flash { padding: 12px 0; text-align: center; font-weight: 500; }
.flash-success { background: #e6f6ec; color: #16794c; }
.flash-error { background: #fdeaea; color: #b3261e; }
.flash-info { background: var(--brand-100); color: var(--brand-600); }
[data-theme="dark"] .flash-success { background: #113322; color: #6adf9c; }
[data-theme="dark"] .flash-error { background: #3a1414; color: #ff8f87; }
[data-theme="dark"] .flash-info { background: #16233f; color: #8fb2ff; }

/* ---------------- Hero ---------------- */
.hero {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
  color: #fff; padding: 90px 0 100px;
}
.hero h1 { color: #fff; font-size: 2.8rem; max-width: 720px; }
.hero p.lead { color: #eaf0ff; font-size: 1.15rem; max-width: 620px; }
.hero-actions { display: flex; gap: 14px; margin-top: 26px; }
.hero-stats { display: flex; gap: 40px; margin-top: 50px; flex-wrap: wrap; }
.hero-stats div strong { display: block; font-size: 1.8rem; }

/* ---------------- Sections ---------------- */
section.section { padding: 70px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.section-head .eyebrow { color: var(--brand-500); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; font-size: .8rem; }

.bg-muted { background: var(--bg-muted); }

/* ---------------- Grids & Cards ---------------- */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; transition: transform var(--transition), box-shadow var(--transition);
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.category-card { text-align: center; padding: 32px 20px; }
.category-card i { font-size: 2.2rem; color: var(--brand-500); margin-bottom: 14px; }
.category-card h3 { margin-bottom: 6px; }
.category-card a { color: inherit; }
.category-card:hover a { text-decoration: none; }

.product-card .product-thumb { aspect-ratio: 16/10; background: var(--bg-muted); overflow: hidden; }
.product-card .product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .product-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-card .badge { align-self: flex-start; }
.product-card .price-row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; }
.product-price { font-size: 1.3rem; font-weight: 700; color: var(--text); }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 20px; background: var(--brand-100); color: var(--brand-600);
}
[data-theme="dark"] .badge { background: #16233f; color: #8fb2ff; }
.badge-accent { background: #fff3e0; color: #b1690a; }
[data-theme="dark"] .badge-accent { background: #3a2a10; color: #ffcd85; }

/* ---------------- Forms ---------------- */
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: .9rem; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-family: var(--font-main); font-size: .95rem;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-500); }
.form-row { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-msg { min-height: 1.4em; font-size: .9rem; }
.form-msg.success { color: #16794c; }
.form-msg.error { color: #b3261e; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; margin: 0 0 20px; }
legend { padding: 0 8px; font-weight: 600; }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }

/* ---------------- Footer ---------------- */
.site-footer { background: var(--footer-bg); color: var(--footer-text); margin-top: 60px; }
.site-footer .brand-name { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 2fr; gap: 30px; padding: 60px 20px 40px; }
.footer-col h4 { color: #fff; font-size: .95rem; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--footer-text); }
.footer-col a:hover { color: #fff; }
.social-links { display: flex; gap: 12px; margin-top: 16px; }
.social-links a { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center; }
.newsletter-form { display: flex; gap: 8px; }
.newsletter-form input { flex: 1; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.08); padding: 18px 0; text-align: center; font-size: .85rem; }

/* ---------------- Cookie banner ---------------- */
.cookie-banner {
  position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 2000; max-width: 900px; margin: 0 auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 22px;
}
.cookie-banner-inner { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.cookie-banner-text { display: flex; gap: 12px; align-items: flex-start; flex: 1; min-width: 260px; }
.cookie-banner-text i { color: var(--accent-500); font-size: 1.4rem; margin-top: 3px; }
.cookie-banner-text p { margin: 0; font-size: .9rem; }
.cookie-banner-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cookie-customize-panel { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.cookie-toggle { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.cookie-toggle span { font-weight: 400; color: var(--text-muted); font-size: .85rem; }
.cookie-toggle input { width: auto; }

/* ---------------- Cart / Checkout ---------------- */
.cart-table img { width: 60px; height: 45px; object-fit: cover; border-radius: 6px; }
.cart-line-item { display: flex; align-items: center; gap: 14px; }
.qty-input { width: 70px; }
.cart-summary { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; position: sticky; top: 100px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; }
.summary-row.total { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 14px; }
#paypal-button-container { margin-top: 20px; }

/* ---------------- Admin shared bits reused on public pages ---------------- */
.alert { padding: 14px 18px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: .92rem; }
.alert-success { background: #e6f6ec; color: #16794c; }
.alert-error { background: #fdeaea; color: #b3261e; }

/* ---------------- Utility ---------------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-4 { gap: 16px; }
.small { font-size: .85rem; }
.text-muted { color: var(--text-muted); }

/* ---------------- Responsive ---------------- */
@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .nav-toggle { display: block; margin-left: auto; }
  .site-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; background: var(--nav-bg);
    transform: translateX(100%); transition: transform var(--transition); overflow-y: auto; padding: 20px;
  }
  .site-nav.open { transform: translateX(0); }
  .site-nav ul { flex-direction: column; }
  .has-dropdown .dropdown { position: static; display: flex; box-shadow: none; border: none; padding-left: 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; padding: 40px 20px; }
  .hero h1 { font-size: 2rem; }
  .cart-summary { position: static; }
}
