/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* Copyright (C) 2024-2026 Philippe Naveau — contact@perfshop.io */
/* PerfShop — Pedagogical Chaos Engineering Platform */
/* https://perfshop.io | https://www.gnu.org/licenses/agpl-3.0.html */

:root {
  --bg: #0a0a0f; --surface: #111118; --surface2: #1a1a24; --border: #2a2a3a;
  --accent: #7c6cfc; --accent2: #4ecdc4; --danger: #ff4757;
  --success: #2ed573; --warning: #ffa502; --text: #e8e8f0; --text2: #8888a8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* LOGIN */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 30% 50%, #1a1040 0%, var(--bg) 60%),
              radial-gradient(ellipse at 70% 20%, #0d2040 0%, transparent 50%); }
.login-box { width: 380px; padding: 48px 40px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 0 60px rgba(124,108,252,0.08); }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo .icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-logo span { font-size: 0.8rem; color: var(--text2); font-family: 'DM Mono', monospace; letter-spacing: 0.1em; text-transform: uppercase; }
.login-error { background: rgba(255,71,87,0.12); border: 1px solid rgba(255,71,87,0.3); color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px; display: none; }
.btn-login { width: 100%; padding: 13px; background: var(--accent); color: white; border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 600; cursor: pointer; margin-top: 8px; transition: opacity 0.2s; }
.btn-login:hover { opacity: 0.85; }

/* FORMS */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 0.78rem; color: var(--text2); margin-bottom: 6px; font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.08em; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 11px 14px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 0.88rem; outline: none; transition: border-color 0.2s; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); }
.form-field select option { background: var(--surface2); }
.form-field textarea { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* APP */
#app { display: none; }
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 100;
  background: rgba(10,10,15,0.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-size: 1.1rem; font-weight: 700; }
.topbar-badge { font-family: 'DM Mono', monospace; font-size: 0.7rem; background: var(--accent); color: white; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.05em; }
.topbar-nav { display: flex; gap: 4px; }
.nav-btn { padding: 7px 16px; border: none; border-radius: 7px; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500; background: transparent; color: var(--text2); transition: all 0.2s; }
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-logout { padding: 7px 14px; background: transparent; border: 1px solid var(--border); border-radius: 7px; color: var(--text2); font-size: 0.8rem; cursor: pointer; font-family: 'DM Mono', monospace; transition: all 0.2s; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }
.main { padding: 80px 24px 40px; max-width: 1400px; margin: 0 auto; }

/* PAGE */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: 0.85rem; color: var(--text2); margin-top: 3px; font-family: 'DM Mono', monospace; }
.page { display: none; }
.page.active { display: block; }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; }
.stat-label { font-size: 0.75rem; color: var(--text2); font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.info { color: var(--accent2); }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 9px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 0.88rem; outline: none; width: 240px; transition: border-color 0.2s; }
.search-input:focus { border-color: var(--accent); }
.filter-select { padding: 9px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 0.88rem; outline: none; cursor: pointer; }
.btn-primary { padding: 9px 18px; background: var(--accent); color: white; border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s; white-space: nowrap; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { padding: 7px 14px; background: transparent; color: var(--accent2); border: 1px solid rgba(78,205,196,0.3); border-radius: 7px; font-size: 0.8rem; cursor: pointer; font-family: 'DM Mono', monospace; transition: all 0.2s; white-space: nowrap; }
.btn-secondary:hover { background: rgba(78,205,196,0.08); }
.btn-danger { padding: 7px 14px; background: rgba(255,71,87,0.12); color: var(--danger); border: 1px solid rgba(255,71,87,0.25); border-radius: 7px; font-size: 0.8rem; cursor: pointer; font-family: 'DM Mono', monospace; transition: all 0.2s; }
.btn-danger:hover { background: rgba(255,71,87,0.2); }
.btn-count { margin-left: auto; font-family: 'DM Mono', monospace; font-size: 0.8rem; color: var(--text2); }

/* TABLE */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; text-align: left; font-size: 0.72rem; color: var(--text2); font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--border); background: var(--surface2); white-space: nowrap; }
td { padding: 12px 16px; font-size: 0.88rem; border-bottom: 1px solid rgba(42,42,58,0.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: 'DM Mono', monospace; font-size: 0.82rem; }
.email-cell { color: var(--accent2); font-family: 'DM Mono', monospace; font-size: 0.82rem; }
.amount { font-weight: 700; color: var(--accent); font-family: 'DM Mono', monospace; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: 0.73rem; font-family: 'DM Mono', monospace; font-weight: 500; letter-spacing: 0.04em; }
.badge-confirmed  { background: rgba(46,213,115,0.12);  color: var(--success); border: 1px solid rgba(46,213,115,0.2); }
.badge-pending    { background: rgba(255,165,2,0.12);   color: var(--warning); border: 1px solid rgba(255,165,2,0.2); }
.badge-processing { background: rgba(124,108,252,0.12); color: var(--accent);  border: 1px solid rgba(124,108,252,0.2); }
.badge-shipped    { background: rgba(78,205,196,0.12);  color: var(--accent2); border: 1px solid rgba(78,205,196,0.2); }
.badge-delivered  { background: rgba(46,213,115,0.12);  color: var(--success); border: 1px solid rgba(46,213,115,0.2); }
.badge-cancelled  { background: rgba(255,71,87,0.12);   color: var(--danger);  border: 1px solid rgba(255,71,87,0.2); }
.badge-standard   { background: rgba(136,136,168,0.1);  color: var(--text2);   border: 1px solid var(--border); }
.badge-express    { background: rgba(255,165,2,0.12);   color: var(--warning); border: 1px solid rgba(255,165,2,0.2); }
.badge-premium    { background: rgba(124,108,252,0.12); color: var(--accent);  border: 1px solid rgba(124,108,252,0.2); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); font-size: 0.9rem; }

/* PRODUCT IMAGE */
.prod-img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.prod-img-ph { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }

/* MODAL */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-bg.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 36px; width: 520px; max-width: 96vw; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.modal-box h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 22px; }
.modal-error   { background: rgba(255,71,87,0.12); border: 1px solid rgba(255,71,87,0.3); color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 0.83rem; margin-bottom: 14px; display: none; }
.modal-success { background: rgba(46,213,115,0.12); border: 1px solid rgba(46,213,115,0.3); color: var(--success); padding: 10px 14px; border-radius: 8px; font-size: 0.83rem; margin-bottom: 14px; display: none; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.btn-cancel { flex: 1; padding: 11px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--text2); font-family: 'DM Sans', sans-serif; cursor: pointer; font-size: 0.9rem; }
.btn-submit { flex: 2; padding: 11px; background: var(--accent); color: white; border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-weight: 600; cursor: pointer; font-size: 0.9rem; transition: opacity 0.2s; }
.btn-submit:hover { opacity: 0.85; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* IMAGE UPLOAD */
.img-upload-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 18px 16px; text-align: center; cursor: pointer; transition: all 0.2s; position: relative; background: var(--surface2); }
.img-upload-zone:hover, .img-upload-zone.drag-over { border-color: var(--accent); background: rgba(124,108,252,0.05); }
.img-upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-hint { font-size: 0.83rem; color: var(--text2); }
.upload-hint strong { color: var(--accent); }
.img-preview { max-width: 100%; max-height: 140px; border-radius: 8px; margin-top: 10px; object-fit: contain; display: none; }
.img-current { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.img-current-preview { width: 100%; max-height: 220px; object-fit: contain; display: block; background: #0d0d14; padding: 12px; }
.img-current-footer { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); }
.img-current-url { font-family: 'DM Mono', monospace; font-size: 0.73rem; color: var(--text2); word-break: break-all; flex: 1; }
.img-no-image { padding: 28px; text-align: center; color: var(--text2); font-size: 0.85rem; }

/* MISC */
.loading { text-align: center; padding: 60px; color: var(--text2); font-family: 'DM Mono', monospace; font-size: 0.85rem; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:0.4} 50%{opacity:1} }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-sep { font-size: 0.72rem; color: var(--text2); font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.1em; margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
