/* =============================================================
   PRINTIT KIOSK DASHBOARD — GLOBAL THEME
   Matches printit-web exactly:
   Light  : #f2f2f2 bg, #111 text, #E8522A accent
   Dark   : #1a1a1a bg, #f5f5f5 text, #E8522A accent
   Font   : Inter (Google Fonts)
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Light (default) ── */
:root {
  --bg: #f2f2f2;
  --bg-muted: #e8e8e8;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.14);
  --border-soft: rgba(0,0,0,0.10);
  --text: #111111;
  --text-muted: #555555;
  --accent: #E8522A;
  --accent-hover: #d44420;
  --accent-text: #ffffff;
  --primary: #111111;
  --primary-text: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow: 0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.18);
  --ease-out: cubic-bezier(0.22,0.61,0.36,1);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w: 260px;
}

/* ── Dark ── */
[data-theme='dark'] {
  --bg: #1a1a1a;
  --bg-muted: #242424;
  --surface: #2a2a2a;
  --border: rgba(255,255,255,0.12);
  --border-soft: rgba(255,255,255,0.08);
  --text: #f5f5f5;
  --text-muted: #999999;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.65);
}

/* ================================
   RESET & BASE
   ================================ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html,body { height: 100%; font-family: var(--font-sans); }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; cursor: pointer; background: none; }
input,select,textarea { font: inherit; }
h1,h2,h3,h4,h5 { font-weight: 800; letter-spacing: -0.01em; color: var(--text); }

/* ================================
   APP LAYOUT
   ================================ */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  transition: transform 0.3s var(--ease-out);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.1;
}

.sidebar-brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--bg-muted); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active svg { color: #fff; }

.nav-item svg { color: var(--text-muted); flex-shrink: 0; }
.nav-item.active svg { color: #fff; }

.nav-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 14px 4px;
}

.sidebar-footer {
  padding: 16px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.top-bar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 48px;
  -webkit-overflow-scrolling: touch;
}

/* ================================
   ICON BUTTON
   ================================ */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-muted); }

/* ================================
   BUTTONS
   ================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
  border: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(232,82,42,0.3);
}
.btn-primary:hover { opacity: 0.9; }

.btn-dark {
  background: var(--text);
  color: var(--surface);
}
.btn-dark:hover { opacity: 0.85; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-muted); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

/* ================================
   STAT CARDS
   ================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card-accent {
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(232,82,42,0.28);
}

.stat-card-dark {
  background: var(--text);
  border-color: transparent;
}

.stat-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card-accent .stat-label,
.stat-card-dark .stat-label {
  color: rgba(255,255,255,0.7);
}

.stat-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-card-accent .stat-value,
.stat-card-dark .stat-value { color: #fff; }

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.stat-card-accent .stat-sub,
.stat-card-dark .stat-sub { color: rgba(255,255,255,0.65); }

.stat-icon {
  margin-bottom: 14px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.stat-card-accent .stat-icon,
.stat-card-dark .stat-icon {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ================================
   SECTION HEADER
   ================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

/* ================================
   PRINTER CARDS (dashboard grid)
   ================================ */
.printers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.printer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.printer-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.printer-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.printer-card-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.printer-card-loc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-online  { background: rgba(34,197,94,0.15); color: #16a34a; }
.badge-offline { background: rgba(156,163,175,0.15); color: #6b7280; }
.badge-error   { background: rgba(239,68,68,0.15); color: #dc2626; }
.badge-printing{ background: rgba(232,82,42,0.15); color: var(--accent); }
.badge-maintenance { background: rgba(245,158,11,0.15); color: #d97706; }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Paper Gauge ── */
.paper-gauge-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paper-gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.paper-gauge-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}

.paper-gauge-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--success);
  transition: width 0.6s var(--ease-out);
}

.paper-gauge-fill.warn { background: var(--warning); }
.paper-gauge-fill.danger { background: var(--danger); }

/* ── Printer card stats row ── */
.printer-card-stats {
  display: flex;
  gap: 12px;
}

.printer-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.printer-stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.printer-stat-value {
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ================================
   CHART CONTAINER
   ================================ */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.chart-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
}

canvas { width: 100% !important; }

/* ================================
   TABLE
   ================================ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 28px;
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 20px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-muted); }

tbody td {
  padding: 12px 20px;
  color: var(--text);
  vertical-align: middle;
}

.td-muted { color: var(--text-muted); font-size: 12px; }

/* ================================
   LOGIN PAGE
   ================================ */
.login-root {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
  animation: slide-up 0.4s cubic-bezier(0.34,1.2,0.64,1) both;
}

@keyframes slide-up {
  from { opacity:0; transform: translateY(24px); }
  to   { opacity:1; transform: translateY(0); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(232,82,42,0.35);
}

.login-title { font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; margin-bottom: 28px; line-height: 1.5; }

/* ── Form ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }

.form-input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,82,42,0.15); }

.btn-login {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232,82,42,0.35);
  transition: opacity 0.15s, transform 0.12s;
}

.btn-login:hover { opacity: 0.9; }
.btn-login:active { transform: scale(0.98); }
.btn-login:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #dc2626;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.login-footer { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 20px; letter-spacing: 0.03em; }

/* ================================
   PRINTER DETAIL PAGE
   ================================ */
.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.detail-hero-left { display: flex; flex-direction: column; gap: 6px; }
.detail-printer-name { font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.detail-printer-id { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; }
.detail-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Big paper gauge (circular) */
.paper-circle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.paper-circle-svg { display: block; }
.paper-circle-text { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ================================
   INFO CARDS ROW
   ================================ */
.info-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.info-card {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.info-card-label { font-size: 10px; font-weight: 800; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.info-card-value { font-size: 20px; font-weight: 900; color: var(--text); letter-spacing: -0.02em; }
.info-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ================================
   MODAL / TOAST
   ================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fade-in 0.2s ease;
  padding: 20px;
}

@keyframes fade-in { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 22px;
  max-width: 420px;
  width: 100%;
  animation: slide-up 0.3s cubic-bezier(0.34,1.1,0.64,1) both;
}

.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.modal-body { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slide-up 0.3s var(--ease-out) both;
  max-width: 320px;
}

.toast.success { background: var(--success); color: #fff; }
.toast.danger  { background: var(--danger);  color: #fff; }

/* ================================
   LOADING SPINNER
   ================================ */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ================================
   EMPTY STATE
   ================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.empty-title { font-size: 16px; font-weight: 800; }
.empty-sub { font-size: 13px; color: var(--text-muted); max-width: 280px; line-height: 1.5; }

/* ================================
   RESPONSIVE — mobile sidebar
   ================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 25;
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.active { display: block; }

  .page-scroll { padding: 20px 16px 48px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .printers-grid { grid-template-columns: 1fr; }
  .top-bar { padding: 12px 16px; }
}

/* ================================
   UTILITY
   ================================ */
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.fw-900 { font-weight: 900; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ── Ripple on buttons ── */
.btn, .btn-login, .btn-primary, .btn-dark, .btn-outline {
  position: relative;
  overflow: hidden;
}

.btn::after, .btn-login::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,255,255,0.15);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:active::after, .btn-login:active::after { opacity: 1; }

/* ── Printer Heartbeat dot ── */
@keyframes pulse-dot {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: 0.6; }
}

.heartbeat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
