/* =========================================================
   Codioz - shared stylesheet
   Theme + light/dark are driven entirely by CSS variables set
   on <html data-theme="..." data-mode="...">. Bootstrap script
   in <head> sets these attributes before first paint, so there
   is never a flash of the wrong theme.
   ========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  transition: background .25s ease, color .25s ease;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------- Light / Dark base ---------------- */
:root[data-mode="light"] {
  --bg-rgb: 246,247,250;
  --surface-rgb: 255,255,255;
  --text: #14161a;
  --text-dim: #5b6270;
  --border-rgb: 20,22,26;
}
:root[data-mode="dark"] {
  --bg-rgb: 12,13,16;
  --surface-rgb: 24,26,31;
  --text: #eef0f4;
  --text-dim: #9aa1ad;
  --border-rgb: 255,255,255;
}
:root { --bg: rgb(var(--bg-rgb)); }

/* =========================================================
   THEME: Glassmorphism
   ========================================================= */
:root[data-theme="glassmorphism"] {
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-head: 'Segoe UI', system-ui, sans-serif;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --radius: 18px;
  --surface: rgba(var(--surface-rgb), .55);
  --border: 1px solid rgba(var(--border-rgb), .12);
  --shadow: 0 8px 32px rgba(0,0,0,.18);
  --blur: blur(16px);
}
:root[data-theme="glassmorphism"] body {
  background: radial-gradient(circle at 20% 0%, rgba(124,92,255,.18), transparent 45%),
              radial-gradient(circle at 90% 20%, rgba(34,211,238,.16), transparent 40%),
              var(--bg);
}
:root[data-theme="glassmorphism"] .card, :root[data-theme="glassmorphism"] .modal-box,
:root[data-theme="glassmorphism"] .site-header, :root[data-theme="glassmorphism"] .panel,
:root[data-theme="glassmorphism"] .toast, :root[data-theme="glassmorphism"] .bottom-nav {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
:root[data-theme="glassmorphism"] .btn {
  border-radius: 999px;
  border: var(--border);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
:root[data-theme="glassmorphism"] input, :root[data-theme="glassmorphism"] select,
:root[data-theme="glassmorphism"] textarea {
  background: rgba(var(--surface-rgb), .5);
  border: var(--border);
  border-radius: 12px;
  backdrop-filter: var(--blur);
}

/* =========================================================
   THEME: Brutalism
   ========================================================= */
:root[data-theme="brutalism"] {
  --font-body: 'Courier New', monospace;
  --font-head: 'Arial Black', Impact, sans-serif;
  --accent: #ff3b30;
  --accent-2: #ffd400;
  --radius: 0px;
  --surface: rgb(var(--surface-rgb));
  --border: 3px solid var(--text);
  --shadow: 6px 6px 0 var(--text);
  --blur: none;
}
:root[data-theme="brutalism"] body { background: var(--bg); }
:root[data-theme="brutalism"] .card, :root[data-theme="brutalism"] .modal-box,
:root[data-theme="brutalism"] .site-header, :root[data-theme="brutalism"] .panel,
:root[data-theme="brutalism"] .toast, :root[data-theme="brutalism"] .bottom-nav {
  background: var(--surface);
  border: var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
}
:root[data-theme="brutalism"] .btn {
  border-radius: 0;
  border: 3px solid var(--text);
  background: var(--accent-2);
  color: var(--text);
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--text);
}
:root[data-theme="brutalism"] .btn:active { box-shadow: 1px 1px 0 var(--text); transform: translate(3px,3px); }
:root[data-theme="brutalism"] input, :root[data-theme="brutalism"] select,
:root[data-theme="brutalism"] textarea {
  background: var(--surface);
  border: 3px solid var(--text);
  border-radius: 0;
}

/* =========================================================
   THEME: Skeuomorphism (phase 2 placeholder look — safe default,
   not fake: falls back to a distinct soft/paper style so nothing
   is broken if selected before the full version ships)
   ========================================================= */
:root[data-theme="skeuomorphism"] {
  --font-body: Georgia, 'Times New Roman', serif;
  --font-head: Georgia, serif;
  --accent: #a9762f;
  --accent-2: #6b4423;
  --radius: 10px;
  --surface: rgb(var(--surface-rgb));
  --border: 1px solid rgba(var(--border-rgb), .25);
  --shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 3px 8px rgba(0,0,0,.25);
  --blur: none;
}
:root[data-theme="skeuomorphism"] body { background: linear-gradient(180deg, rgba(0,0,0,.04), transparent 200px), var(--bg); }
:root[data-theme="skeuomorphism"] .card, :root[data-theme="skeuomorphism"] .modal-box,
:root[data-theme="skeuomorphism"] .site-header, :root[data-theme="skeuomorphism"] .panel,
:root[data-theme="skeuomorphism"] .toast, :root[data-theme="skeuomorphism"] .bottom-nav {
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(0,0,0,.03)), var(--surface);
  border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
:root[data-theme="skeuomorphism"] .btn {
  border-radius: 8px; border: 1px solid rgba(0,0,0,.25); color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 2px 4px rgba(0,0,0,.3);
}

/* =========================================================
   THEME: Futuristic (phase 2 placeholder look — distinct neon style)
   ========================================================= */
:root[data-theme="futuristic"] {
  --font-body: 'Consolas', 'Segoe UI', monospace;
  --font-head: 'Consolas', monospace;
  --accent: #00f0ff;
  --accent-2: #ff00c8;
  --radius: 4px;
  --surface: rgba(var(--surface-rgb), .7);
  --border: 1px solid rgba(0,240,255,.5);
  --shadow: 0 0 18px rgba(0,240,255,.25);
  --blur: blur(6px);
}
:root[data-theme="futuristic"] body { background: linear-gradient(160deg, #05060a, #0b0f1a); --text: #d8fbff; }
:root[data-theme="futuristic"] .card, :root[data-theme="futuristic"] .modal-box,
:root[data-theme="futuristic"] .site-header, :root[data-theme="futuristic"] .panel,
:root[data-theme="futuristic"] .toast, :root[data-theme="futuristic"] .bottom-nav {
  background: var(--surface); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: var(--blur);
}
:root[data-theme="futuristic"] .btn {
  border-radius: 2px; border: 1px solid var(--accent); color: var(--accent);
  background: transparent; text-transform: uppercase; letter-spacing: 1px;
}
:root[data-theme="futuristic"] .btn:hover { box-shadow: 0 0 14px var(--accent); }

/* ---------------------------------------------------------
   Layout primitives shared by all themes
   --------------------------------------------------------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.card { padding: 16px; }
.panel { padding: 20px; }
.btn { padding: 10px 20px; font-size: 15px; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.btn:hover { transform: translateY(-2px); }
.btn.secondary { background: transparent; border: 1px solid var(--text-dim); color: var(--text); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.site-header {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center;
  justify-content: space-between; padding: 12px 20px; margin: 10px; gap: 12px;
  animation: header-in .5s ease both;
}
@keyframes header-in { from { opacity: 0; transform: translateY(-14px);} to { opacity: 1; transform: translateY(0);} }
.logo { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 800; font-size: 20px; }
.logo img { height: 32px; width: auto; border-radius: 6px; }
.nav-desktop { display: flex; gap: 18px; align-items: center; }
.nav-desktop a, .nav-desktop button.linklike {
  background: none; border: none; color: var(--text); cursor: pointer; font-size: 15px; padding: 6px 4px;
  border-bottom: 2px solid transparent; transition: border-color .2s ease, color .2s;
}
.nav-desktop a:hover, .nav-desktop button.linklike:hover { border-color: var(--accent); }
.icon-btn { background: none; border: 1px solid var(--text-dim); border-radius: 50%; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.menu-btn { display: none; }

.mobile-menu { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: none; }
.mobile-menu.open { display: block; animation: fade-in .2s ease; }
.mobile-menu-panel { position: absolute; top: 0; right: 0; width: 78%; max-width: 320px; height: 100%; padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; animation: slide-in .25s ease; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0;} to { transform: translateX(0); opacity: 1;} }
@keyframes fade-in { from { opacity: 0;} to { opacity: 1;} }
.mobile-menu-panel a, .mobile-menu-panel button { font-size: 17px; text-align: left; background: none; border: none; color: var(--text); padding: 10px 0; cursor: pointer; }

@media (max-width: 860px) {
  .nav-desktop { display: none; }
  .menu-btn { display: inline-flex; }
}

.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; padding: 30px 16px; animation: fade-up .5s ease both; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(16px);} to { opacity: 1; transform: translateY(0);} }
.hero h1 { font-family: var(--font-head); font-size: clamp(28px, 4vw, 44px); margin: 0 0 12px; }
.hero p { color: var(--text-dim); font-size: 16px; }
.hero-img { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.grid-products { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 10px 0; }
@media (max-width: 860px) { .grid-products { grid-template-columns: repeat(2, 1fr); } }
.product-card { overflow: hidden; cursor: pointer; animation: fade-up .4s ease both; }
.product-card:hover { transform: translateY(-4px); }
.product-thumb { aspect-ratio: 1/1; overflow: hidden; border-radius: calc(var(--radius) - 4px); }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.product-card:hover .product-thumb img { transform: scale(1.06); }
.product-title { font-weight: 700; margin: 10px 0 4px; }
.product-desc { color: var(--text-dim); font-size: 13px; margin: 0 0 8px; }
.price-row { display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 800; }
.price.free { color: #22c55e; }
.discount-badge { background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; animation: fade-in .2s ease; }
.modal-box { width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 22px; animation: modal-in .25s cubic-bezier(.2,.8,.2,1); position: relative; }
@keyframes modal-in { from { opacity: 0; transform: scale(.94) translateY(10px);} to { opacity: 1; transform: scale(1) translateY(0);} }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-dim); }

.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 150; width: 100%; max-width: 380px; padding: 0 16px; }
.toast { padding: 12px 16px; font-size: 14px; animation: toast-in .25s ease, toast-out .25s ease 2.6s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px);} to { opacity: 1; transform: translateY(0);} }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
.toast.error { border-color: #ef4444 !important; }

.bottom-nav { position: fixed; bottom: 10px; left: 10px; right: 10px; display: none; justify-content: space-around; padding: 10px; z-index: 50; }
@media (max-width: 860px) { .bottom-nav.active { display: flex; } }
.bottom-nav button { background: none; border: none; color: var(--text-dim); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; cursor: pointer; }
.bottom-nav button.active { color: var(--accent); }

.skeleton { background: linear-gradient(90deg, rgba(128,128,128,.15) 25%, rgba(128,128,128,.28) 37%, rgba(128,128,128,.15) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 0;} 100% { background-position: -100% 0;} }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(128,128,128,.35); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg);} }

.empty-state { text-align: center; padding: 60px 16px; color: var(--text-dim); animation: fade-up .4s ease both; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-dim); }
.field input, .field select, .field textarea { padding: 10px 12px; color: var(--text); }
.field textarea { min-height: 90px; resize: vertical; }

footer.site-footer { margin: 40px 10px 10px; padding: 26px 20px; display: grid; gap: 16px; }
.social-row { display: flex; gap: 10px; flex-wrap: wrap; }
.social-row a { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; align-items: center; justify-content: center; border: 1px solid var(--text-dim); }

.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
@media (max-width: 860px) { .admin-shell { grid-template-columns: 1fr; } }
.admin-sidebar { padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow: auto; animation: slide-in-left .3s ease; }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-14px);} to { opacity: 1; transform: translateX(0);} }
.admin-sidebar button { text-align: left; background: none; border: none; color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.admin-sidebar button.active { background: var(--accent); color: #fff; }
.admin-main { padding: 20px; }
.admin-section { display: none; animation: fade-up .3s ease both; }
.admin-section.active { display: block; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(var(--border-rgb), .12); vertical-align: top; }

.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; display: inline-block; }
.badge.pending { background: #f59e0b; color: #fff; }
.badge.accepted, .badge.delivered { background: #22c55e; color: #fff; }
.badge.rejected { background: #ef4444; color: #fff; }
.badge.processing { background: #3b82f6; color: #fff; }

.typing-code { font-family: 'Consolas', monospace; font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; background: #0d1117; color: #c9d1d9; padding: 16px; border-radius: 12px; }
.cursor-blink::after { content: '▍'; animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chat-msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; margin-bottom: 8px; animation: fade-up .25s ease both; }
.chat-msg.mine { margin-left: auto; background: var(--accent); color: #fff; }
.chat-msg.theirs { background: var(--surface); border: var(--border); }
.chat-msg .msg-del { background:none; border:none; cursor:pointer; color:inherit; opacity:.6; font-size:11px; margin-left:8px; }
.chat-msg .msg-del:hover { opacity:1; }

.inbox-shell { display: grid; grid-template-columns: 280px 1fr; gap: 14px; height: 68vh; }
@media (max-width: 860px) { .inbox-shell { grid-template-columns: 1fr; height: auto; } }
.inbox-list { overflow-y: auto; padding: 8px; }
.conv-item { padding: 10px; border-radius: 10px; cursor: pointer; margin-bottom: 4px; display:flex; justify-content:space-between; align-items:center; gap:8px; }
.conv-item:hover, .conv-item.active { background: rgba(var(--border-rgb), .08); }
.conv-item .conv-meta { overflow: hidden; }
.conv-item .conv-contact { font-weight: 700; font-size: 13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-item .conv-last { font-size: 12px; color: var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:170px; }
.unread-dot { background: var(--accent); color:#fff; border-radius:999px; font-size:11px; padding:1px 7px; flex-shrink:0; }
.inbox-thread { display: flex; flex-direction: column; overflow: hidden; }
.chat-log-wrap { flex: 1; overflow-y: auto; padding: 6px; }
