/* ══════════════════════════════════════════════════════════════════════
   EXPERT CELL DASHBOARD — APPLE STYLE (FINAL)
   Palette: Apple Human Interface Guidelines Dark Mode
   ══════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg:          #000000;
  --surface:     #1c1c1e;   /* Apple systemGray6 Dark */
  --surface2:    #2c2c2e;   /* Apple systemGray5 Dark */
  --separator:   #38383a;   /* Apple separator Dark   */
  --label:       #f5f5f7;
  --label2:      #ebebf5cc; /* Apple secondaryLabel   */
  --label3:      #ebebf54d;
  --gold:        #ffffff;   /* Apple Monochrome Standard (APROVADO) */
  --green:       #30d158;
  --red:         #ff453a;
  --blue:        #0a84ff;
  --radius:      16px;
  --radius-lg:   24px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--label); font-family: var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }

/* ── LOGIN SCREEN ─────────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
#login-screen.hidden { display: none; }
.login-box { width: 340px; text-align: center; }
.login-box h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.login-box p  { color: var(--label2); font-size: 0.9rem; margin-bottom: 40px; }
.login-box input {
  width: 100%; background: var(--surface); border: 1px solid var(--separator);
  border-radius: 12px; padding: 14px 18px; color: #fff; font-size: 1rem; outline: none;
  margin-bottom: 16px; text-align: center; letter-spacing: 4px;
}
.login-box input:focus { border-color: var(--gold); }
.login-box button {
  width: 100%; background: var(--gold); color: #000; border: none;
  border-radius: 12px; padding: 14px; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.login-error { color: var(--red); font-size: 0.85rem; margin-top: 12px; display: none; }

/* ── LAYOUT ───────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
#app.hidden { display: none; }

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
#sidebar {
  width: 260px; height: 100vh; background: var(--surface);
  border-right: 1px solid var(--separator);
  position: fixed; left: 0; top: 0; z-index: 800;
  overflow-y: auto; scrollbar-width: none;
  transition: transform 0.45s cubic-bezier(.4,0,.2,1);
}
#sidebar::-webkit-scrollbar { display: none; }
#sidebar.collapsed { transform: translateX(-260px); }

@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); z-index: 1100; }
  #sidebar.mobile-open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.8); }
}

.sidebar-brand { padding: 28px 20px 24px; display: flex; align-items: center; gap: 10px; }
.sidebar-brand span:first-child { font-size: 1.6rem; }
.sidebar-brand span:last-child  { font-weight: 700; color: var(--gold); font-size: 1.05rem; text-transform: uppercase; letter-spacing: .02em; }

.menu-item {
  padding: 10px 20px; display: flex; align-items: center; justify-content: space-between;
  color: var(--label2); cursor: pointer; font-size: 0.9rem; font-weight: 400;
  transition: background .15s;
}
.menu-item:hover { background: rgba(255,255,255,.04); }
.menu-item.active { color: var(--gold); font-weight: 600; background: rgba(201,168,76,.08); }
.menu-badge { font-size: .7rem; color: var(--label3); min-width: 20px; text-align: right; }
.menu-section { padding: 20px 20px 6px; font-size: .65rem; color: var(--label3); text-transform: uppercase; font-weight: 700; letter-spacing: .08em; }

/* ── MAIN ─────────────────────────────────────────────────────────────── */
#main-wrap {
  flex: 1; margin-left: 260px; display: flex; flex-direction: column;
  transition: margin .45s cubic-bezier(.4,0,.2,1);
}
#sidebar.collapsed ~ #main-wrap { margin-left: 0; }
@media (max-width: 900px) { #main-wrap { margin-left: 0; } }

/* Header */
.top-bar {
  position: sticky; top: 0; z-index: 700;
  background: rgba(0,0,0,.85); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator); padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.top-bar-left { display: flex; align-items: center; gap: 16px; }
.hamburger { background: none; border: none; color: var(--gold); cursor: pointer; display: flex; align-items: center; }

.search-wrap { flex: 1; max-width: 400px; position: relative; }
.search-wrap input {
  width: 100%; background: var(--surface); border: 1px solid var(--separator);
  border-radius: 10px; padding: 9px 14px 9px 36px; color: #fff; font-size: .88rem; outline: none;
}
.search-wrap input:focus { border-color: var(--gold); }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--label3); }

.top-actions { display: flex; gap: 10px; }
.action-btn {
  background: var(--surface); border: 1px solid var(--separator);
  color: var(--label2); padding: 8px 16px; border-radius: 10px;
  font-weight: 600; font-size: .85rem; cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: .2s;
}
.action-btn:hover { border-color: var(--gold); color: var(--gold); }
.action-btn svg { width: 16px; height: 16px; }

/* ── GRID ─────────────────────────────────────────────────────────────── */
.grid-area { padding: 28px 24px; flex: 1; }
#products-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px;
}

/* ── CARDS ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--separator); transition: transform .3s, border-color .3s, box-shadow .3s;
  position: relative; cursor: pointer;
}
.card:hover { transform: translateY(-6px); border-color: var(--gold); box-shadow: 0 16px 48px rgba(0,0,0,.6); }

.card-supplier-tag {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  padding: 4px 10px; border-radius: 6px; font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: #fff;
}
.tag-ipcell { background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.1); }
.tag-pronta { background: rgba(48, 209, 88, 0.2); backdrop-filter: blur(4px); color: var(--green); border: 1px solid rgba(48, 209, 88, 0.2); }
.tag-swap { background: rgba(10, 132, 255, 0.2); backdrop-filter: blur(4px); color: var(--blue); border: 1px solid rgba(10, 132, 255, 0.2); }

.card-img {
  height: 240px; background: #0a0a0a; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.card-img img, .card-img video { width: 100%; height: 100%; object-fit: cover; }
.card-img .ph { 
  width: 100%; height: 100%; 
  background: linear-gradient(145deg, #1c1c1e 0%, #0a0a0a 100%);
  position: relative;
}
.card-img .ph::after {
  content: "";
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 64px; color: rgba(255,255,255,0.03);
}

.card-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.65); backdrop-filter: blur(6px);
  border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 18px; z-index: 6; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.card:hover .card-nav { opacity: 1; }
.card-nav.prev { left: 10px; }
.card-nav.next { right: 10px; }

.card-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: .2s; z-index: 5; }
.card:hover .card-tools { opacity: 1; }
.card-tool { width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.card-tool.edit { background: rgba(0,0,0,.65); color: #fff; backdrop-filter: blur(4px); }
.card-tool.del  { background: var(--red); color: #fff; }

.card-body { padding: 16px 18px 20px; }
.card-model { font-weight: 600; font-size: 1rem; margin-bottom: 3px; }
.card-specs { font-size: .8rem; color: var(--label2); margin-bottom: 12px; }
.card-price { font-size: 1.4rem; font-weight: 700; color: var(--gold); }
.card-installment { font-size: .75rem; color: var(--label3); margin-top: 4px; }

/* ── MODAL ─────────────────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(12px);
}
.modal-bg.active { display: flex; }

.modal-box {
  background: var(--surface); border-radius: 28px; width: 92%; max-width: 960px;
  max-height: 88vh; display: flex; overflow: hidden; border: 1px solid var(--separator);
  position: relative;
}
@media (max-width: 700px) { .modal-box { flex-direction: column; max-height: 94vh; } }

.modal-media { flex: 1; background: #0a0a0a; display: flex; align-items: center; justify-content: center; min-height: 300px; position: relative; }
.modal-media img, .modal-media video { width: 100%; height: 100%; object-fit: cover; }

.modal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.5); backdrop-filter: blur(10px);
  border: none; color: #fff; width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; font-size: 24px; z-index: 20; display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .2s;
}
.modal-nav:hover { background: rgba(0,0,0,.8); transform: translateY(-50%) scale(1.1); }
.modal-nav.prev { left: 16px; }
.modal-nav.next { right: 16px; }

.modal-counter {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); backdrop-filter: blur(10px);
  padding: 6px 14px; border-radius: 20px; color: #fff; font-size: 0.8rem; font-weight: 600;
  z-index: 20; letter-spacing: 0.05em;
}

.modal-detail { flex: 1; padding: 44px 36px; overflow-y: auto; }
.modal-detail h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; line-height: 1.15; }
.modal-detail .specs { color: var(--label2); font-size: .9rem; margin-bottom: 28px; }
.modal-detail .price-tag { font-size: 2.4rem; font-weight: 800; color: var(--gold); margin-bottom: 32px; }

.modal-close {
  position: absolute; top: 20px; right: 24px; background: var(--surface2); border: none;
  color: var(--label); width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center; z-index: 10;
}

.parcelas-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.parcelas-table th { text-align: left; color: var(--label3); font-size: .7rem; text-transform: uppercase; padding-bottom: 8px; font-weight: 600; }
.parcelas-table td { padding: 10px 0; border-top: 1px solid var(--separator); }
.parcelas-table .mp { color: var(--gold); }

/* ── DRAWERS ──────────────────────────────────────────────────────────── */
.drawer {
  position: fixed; top: 0; width: 420px; height: 100vh; background: var(--surface);
  z-index: 1200; padding: 36px 28px; border-left: 1px solid var(--separator);
  overflow-y: auto; transition: transform .4s cubic-bezier(.4,0,.2,1);
}
.drawer.right { right: 0; transform: translateX(100%); }
.drawer.right.open { transform: translateX(0); box-shadow: -12px 0 40px rgba(0,0,0,.6); }

.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.drawer-head h2 { font-size: 1.2rem; font-weight: 700; }
.drawer-close { background: none; border: none; color: var(--label2); font-size: 22px; cursor: pointer; }

/* ── OVERLAY ──────────────────────────────────────────────────────────── */
.overlay-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1100; display: none; }
.overlay-bg.show { display: block; }

/* ── FORM ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .7rem; color: var(--label3); text-transform: uppercase; font-weight: 600; letter-spacing: .05em; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--separator); border-radius: 10px;
  padding: 11px 14px; color: #fff; font-size: .9rem; outline: none; font-family: var(--font);
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-gold { background: var(--gold); color: #000; border: none; padding: 13px 24px; border-radius: 12px; font-weight: 700; font-size: .9rem; cursor: pointer; width: 100%; }
.btn-dark  { background: var(--surface2); color: var(--label); border: 1px solid var(--separator); padding: 11px 18px; border-radius: 10px; font-weight: 500; font-size: .85rem; cursor: pointer; width: 100%; }

/* ── SCRIPT TABS ──────────────────────────────────────────────────────── */
.script-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.script-tab {
  padding: 7px 14px; border-radius: 8px; font-size: .78rem; font-weight: 600;
  background: var(--surface2); color: var(--label2); cursor: pointer; border: none;
}
.script-tab.active { background: var(--gold); color: #000; }

.script-content { background: var(--bg); border: 1px solid var(--separator); border-radius: 14px; padding: 20px; }
.script-content textarea {
  width: 100%; min-height: 180px; background: none; border: none; color: var(--label);
  font-family: 'Inter', monospace; font-size: .88rem; line-height: 1.6; resize: none; outline: none;
}

/* ── TOAST ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #000; padding: 10px 28px; border-radius: 50px;
  font-weight: 700; font-size: .9rem; z-index: 9000;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(16px); } }

#empty-state { display: none; text-align: center; padding: 100px 0; color: var(--label3); font-size: 1rem; }

/* -- SLIDERS (APPLE STYLE) ----------------------------------------------- */
input[type="range"] {
  -webkit-appearance: none;
  background: transparent;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: var(--separator);
  border-radius: 2px;
}
