/* ============================================================
   Theme system. Colors are driven by CSS variables so the whole
   UI restyles by switching [data-theme] on <html>.
   Themes: light (default), dark, futuristic (neon).
   ============================================================ */
:root,
:root[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-2: #eef1f5;
  --card: #ffffff;
  --line: #e2e6ea;
  --text: #1c2733;
  --heading: #1f3a5f;
  --muted: #6b7785;
  --accent: #1f8a70;
  --accent-soft: #eef4f1;
  --danger: #c0392b;
  --topbar-bg: #1f3a5f;
  --topbar-text: #ffffff;
  --sidebar-bg: #ffffff;
  --input-bg: #ffffff;
  --th-bg: #1f3a5f;
  --th-text: #ffffff;
  --hover-bg: #fafbfc;
  --btn-bg: #1f3a5f;
  --btn-text: #ffffff;
  --btn-hover: #16293f;
  --tag-bg: #eef4f1;
  --tag-text: #1f8a70;
  --shadow: 0 10px 40px rgba(0,0,0,0.08);
  --shadow-strong: 0 10px 40px rgba(0,0,0,0.2);
  --radius: 10px;
  --glow: none;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #11161c;
  --bg-2: #161d26;
  --card: #1b232d;
  --line: #2a343f;
  --text: #e7ecf1;
  --heading: #ffffff;
  --muted: #9aa6b2;
  --accent: #2ec96f;
  --accent-soft: #16302a;
  --danger: #e06b5d;
  --topbar-bg: #0c1016;
  --topbar-text: #ffffff;
  --sidebar-bg: #161d26;
  --input-bg: #11161c;
  --th-bg: #232d38;
  --th-text: #ffffff;
  --hover-bg: #20293440;
  --btn-bg: #2ec96f;
  --btn-text: #0c1016;
  --btn-hover: #27b261;
  --tag-bg: #16302a;
  --tag-text: #6fe6a1;
  --shadow: 0 10px 40px rgba(0,0,0,0.4);
  --shadow-strong: 0 10px 40px rgba(0,0,0,0.6);
  --radius: 10px;
  --glow: none;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Futuristic: deep space + neon cyan/magenta, glassy cards, subtle glow. */
:root[data-theme="futuristic"] {
  --bg: #070b16;
  --bg-2: #0b1224;
  --card: rgba(18, 28, 51, 0.72);
  --line: #1d2c52;
  --text: #d6e4ff;
  --heading: #6ff7ff;
  --muted: #7d8cb5;
  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.12);
  --danger: #ff4d7d;
  --topbar-bg: linear-gradient(90deg, #0a1330, #11203f);
  --topbar-text: #aef6ff;
  --sidebar-bg: rgba(11, 18, 36, 0.85);
  --input-bg: rgba(8, 14, 30, 0.85);
  --th-bg: linear-gradient(90deg, #112047, #15264f);
  --th-text: #8af0ff;
  --hover-bg: rgba(0, 229, 255, 0.06);
  --btn-bg: linear-gradient(90deg, #00e5ff, #4d7cff);
  --btn-text: #051026;
  --btn-hover: linear-gradient(90deg, #28ecff, #6a92ff);
  --tag-bg: rgba(0, 229, 255, 0.14);
  --tag-text: #6ff7ff;
  --shadow: 0 0 0 1px rgba(0,229,255,0.08), 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-strong: 0 0 30px rgba(0, 229, 255, 0.25), 0 12px 50px rgba(0,0,0,0.7);
  --radius: 14px;
  --glow: 0 0 14px rgba(0, 229, 255, 0.35);
  --font: "Segoe UI", system-ui, Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background .25s ease, color .25s ease;
}
:root[data-theme="futuristic"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(77,124,255,0.18), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(0,229,255,0.12), transparent),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { color: var(--heading); }
:root[data-theme="futuristic"] h1,
:root[data-theme="futuristic"] h2 { text-shadow: var(--glow); letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); margin-top: 0.5rem; }

button {
  background: var(--btn-bg); color: var(--btn-text); border: none;
  padding: 0.55rem 0.9rem; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
  font-weight: 600; transition: filter .15s ease, transform .05s ease, box-shadow .2s ease;
}
button:hover { background: var(--btn-hover); }
:root[data-theme="futuristic"] button:hover { box-shadow: var(--glow); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; color: var(--heading); border: 1px solid var(--line); }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

input, select {
  width: 100%; padding: 0.5rem; border: 1px solid var(--line);
  border-radius: 8px; font-size: 0.95rem; margin-bottom: 0.75rem;
  background: var(--input-bg); color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--card); padding: 2rem; border-radius: var(--radius); width: 340px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.login-card h1 { margin: 0 0 0.25rem; }

/* App shell */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--topbar-bg); color: var(--topbar-text); padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { color: var(--topbar-text); font-size: 1.1rem; margin: 0; }
.topbar .user { font-size: 0.85rem; opacity: 0.9; }
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar { width: 210px; background: var(--sidebar-bg); border-right: 1px solid var(--line); padding: 1rem 0; }
.sidebar a {
  display: block; padding: 0.6rem 1.2rem; color: var(--text); text-decoration: none; font-size: 0.92rem;
  transition: background .15s ease;
}
.sidebar a:hover { background: var(--hover-bg); }
.sidebar a.active { background: var(--accent-soft); border-left: 3px solid var(--accent); font-weight: 600; color: var(--heading); }
.content { flex: 1; padding: 1.5rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
th { background: var(--th-bg); color: var(--th-text); font-weight: 600; }
tr:hover td { background: var(--hover-bg); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.tag { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; background: var(--tag-bg); color: var(--tag-text); }
.matrix-grid { display: grid; gap: 0.4rem 0.8rem; align-items: center; }
.hidden { display: none; }
dialog {
  border: none; border-radius: var(--radius); padding: 1.5rem; width: 380px;
  box-shadow: var(--shadow-strong); background: var(--card); color: var(--text);
  border: 1px solid var(--line);
}
dialog::backdrop { background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); }
.checks label { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
.checks input { width: auto; margin: 0; }

/* Dish image cards (Master Data + Order pages) */
.dish-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.dish-tile { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.dish-img { height: 120px; background-size: cover; background-position: center; background-color: #000; position: relative; }
.dish-img .oos { position: absolute; top: 8px; right: 8px; background: var(--danger); color: #fff; font-size: .7rem; padding: .1rem .5rem; border-radius: 999px; }
.dish-info { padding: .7rem .8rem; }
.dish-name { font-weight: 700; color: var(--heading); }
.dish-meta { font-size: .8rem; color: var(--text); margin-top: .2rem; }
.dish-actions { display: flex; gap: .3rem; margin-top: .6rem; flex-wrap: wrap; }

/* Theme toggle button (injected by theme.js) */
.theme-toggle {
  background: transparent; color: var(--topbar-text);
  border: 1px solid rgba(255,255,255,0.35); border-radius: 999px;
  padding: 0.3rem 0.7rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: .35rem;
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }
