/* Coop TV — Admin CSS v2.2 */

/* ---- Temas ---- */
:root {
  --bg: #0f1117; --bg2: #1a1d2e; --bg3: #232640; --border: #2e3250;
  --text: #e2e8f0; --muted: #64748b; --primary: #6366f1; --primary-d: #4f46e5;
  --green: #22c55e; --red: #ef4444; --orange: #f97316; --blue: #3b82f6; --purple: #a855f7;
  --radius: 12px; --shadow: 0 4px 24px rgba(0,0,0,.4); --sidebar-w: 220px;
}
[data-theme="light"] {
  --bg: #f0f2f8; --bg2: #fff; --bg3: #f1f3f9; --border: #dde1ef;
  --text: #1e2340; --muted: #6b7280; --primary: #4340d4; --primary-d: #3730a3;
  --shadow: 0 4px 24px rgba(0,0,0,.1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: monospace; background: var(--bg3); padding: .1em .4em; border-radius: 4px; font-size: .85em; }
hr { border: none; border-top: 1px solid var(--border); }
small { color: var(--muted); font-size: .8rem; }

/* ---- Layout ---- */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

/* Logo — container fixo, imagem nunca vaza */
.sidebar-brand {
  height: 70px;
  min-height: 70px;
  max-height: 70px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-brand img {
  max-width: 148px;
  max-height: 44px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Nav */
.sidebar-nav {
  padding: 8px 5px; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; text-decoration: none; white-space: nowrap;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 15px; text-align: center; font-size: 13px; flex-shrink: 0; }

/* Footer sidebar */
.sidebar-footer {
  padding: 9px 13px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.footer-user { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; overflow: hidden; min-width: 0; }
.footer-user i { color: var(--primary); flex-shrink: 0; }
.footer-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-logout { color: var(--muted); font-size: 14px; padding: 4px; border-radius: 6px; line-height: 1; }
.footer-logout:hover { color: var(--red); background: var(--bg3); }

/* Dev (Coop) */
.sidebar-dev { padding: 5px 12px 9px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-dev a { display: flex; align-items: center; gap: 6px; text-decoration: none; opacity: .4; transition: opacity .2s; }
.sidebar-dev a:hover { opacity: .85; text-decoration: none; }
.sidebar-dev img { max-width: 76px; max-height: 11px; width: auto; height: auto; display: block; flex-shrink: 0; }
.sidebar-dev span { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* Main */
.main { flex: 1; min-width: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  padding: 13px 22px; border-bottom: 1px solid var(--border); background: var(--bg2);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.page-title { font-size: 15px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 9px; }
.theme-toggle {
  width: 34px; height: 34px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  transition: background .15s, border-color .15s, color .15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.topbar-version { font-size: 11px; color: var(--muted); font-family: monospace; }
.content { flex: 1; overflow-y: auto; padding: 22px; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 17px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.card-body { padding: 17px; }
.card-body.p0 { padding: 0; }

/* Grid & Stats */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dash-grid-1col { grid-template-columns: 1fr; }
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; display: flex; align-items: flex-start; gap: 12px; }
.stat-card.blue   { border-left: 4px solid var(--blue); }
.stat-card.green  { border-left: 4px solid var(--green); }
.stat-card.purple { border-left: 4px solid var(--purple); }
.stat-card.orange { border-left: 4px solid var(--orange); }
.stat-icon { font-size: 19px; padding: 8px; background: var(--bg3); border-radius: 8px; flex-shrink: 0; line-height: 1; }
.stat-info { min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); font-size: 11px; margin: 3px 0 2px; }
.stat-sub   { font-size: 10.5px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s; text-decoration: none; white-space: nowrap; line-height: 1; }
.btn:hover { background: var(--border); text-decoration: none; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-green  { background: var(--green);  border-color: var(--green);  color: #fff; }
.btn-red    { background: var(--red);    border-color: var(--red);    color: #fff; }
.btn-purple { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-blue   { background: var(--blue);   border-color: var(--blue);   color: #fff; }
.btn-green:hover, .btn-red:hover, .btn-purple:hover, .btn-blue:hover { filter: brightness(1.1); }
.btn-sm   { padding: 4px 9px; font-size: 11.5px; }
.btn-full { width: 100%; justify-content: center; padding: 10px; }
.btn-row  { display: flex; gap: 9px; margin-top: 17px; }

/* Forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 13px; font-size: 13px; transition: border-color .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field input::placeholder { color: var(--muted); }
.field small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.input-icon input { padding-left: 36px; }
.checkbox-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text); }
.checkbox-label input { width: auto; }
.settings-section { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 17px 0 11px; padding-bottom: 5px; border-bottom: 1px solid var(--border); font-weight: 700; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 9px 15px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.table td { padding: 8px 15px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg3); }
.actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge-blue   { background: #3b82f620; color: var(--blue); }
.badge-green  { background: #22c55e20; color: var(--green); }
.badge-orange { background: #f9731620; color: var(--orange); }
.badge-purple { background: #a855f720; color: var(--purple); }
.badge-red    { background: #ef444420; color: var(--red); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; display: flex; align-items: center; gap: 9px; font-size: 13px; }
.alert-success { background: #22c55e20; border: 1px solid #22c55e40; color: var(--green); }
.alert-error   { background: #ef444420; border: 1px solid #ef444440; color: var(--red); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
[data-theme="dark"] .login-page { background: radial-gradient(ellipse at 50% 0%, #1a1330 0%, #0f1117 70%); }
.login-box { width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.login-logo img { max-width: 160px; max-height: 80px; width: auto; height: auto; object-fit: contain; display: block; margin: 0 auto; }
.brand-tagline { font-size: 11px; color: var(--muted); margin-top: 7px; }
.login-form .field { margin-bottom: 14px; }
.login-theme-toggle { position: fixed; top: 16px; right: 16px; width: 36px; height: 36px; background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: var(--shadow); }
.login-theme-toggle:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.login-dev { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 11px; color: var(--muted); }
.login-dev img { max-width: 70px; max-height: 11px; width: auto; height: auto; opacity: .5; }

/* Upload */
.upload-area { border: 2px dashed var(--border); border-radius: 12px; padding: 36px 28px; text-align: center; transition: border-color .2s, background .2s; cursor: pointer; }
.upload-area:hover { border-color: var(--primary); background: var(--bg3); }
.upload-icon { font-size: 36px; color: var(--primary); margin-bottom: 10px; }
.upload-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px; padding: 11px 14px; background: var(--bg3); border-radius: 8px; margin-top: 8px; font-size: 13px; }
.upload-item-info { display: flex; flex-direction: column; gap: 2px; }
.upload-name { font-weight: 500; }
.upload-size { color: var(--muted); font-size: 11px; }
.progress-bar { height: 4px; background: var(--border); border-radius: 999px; overflow: hidden; grid-column: 1/-1; }
.progress-fill { height: 100%; background: var(--primary); transition: width .1s; }
.upload-status { color: var(--muted); font-size: 11px; text-align: right; }

/* Media */
.media-thumb { width: 60px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg3); }
.search-box { position: relative; }
.search-box i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.search-box input { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px 6px 28px; color: var(--text); font-size: 12.5px; width: 220px; }
.search-box input:focus { outline: none; border-color: var(--primary); }

/* Timeline */
.timeline-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.store-selector-wrap { display: flex; align-items: center; gap: 9px; }
.store-selector-wrap label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.store-selector-wrap select { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 6px 11px; font-size: 13px; }
.timeline-actions { display: flex; align-items: center; gap: 9px; }
.timeline-layout { display: grid; grid-template-columns: 285px 1fr; gap: 18px; height: calc(100vh - 205px); }
.media-panel { display: flex; flex-direction: column; overflow: hidden; }
.media-panel .card-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 0; }
.media-search { padding: 7px; border-bottom: 1px solid var(--border); }
.media-search input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; color: var(--text); font-size: 12.5px; }
.media-search input:focus { outline: none; border-color: var(--primary); }
.media-lib { flex: 1; overflow-y: auto; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.lib-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; cursor: grab; border: 1px solid transparent; transition: background .15s, border-color .15s; user-select: none; }
.lib-item:hover { background: var(--bg3); border-color: var(--border); }
.lib-item:active { cursor: grabbing; }
.lib-thumb { position: relative; width: 52px; height: 33px; flex-shrink: 0; border-radius: 5px; overflow: hidden; background: var(--bg3); }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-icon { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 17px; }
.lib-badge { position: absolute; bottom: 2px; right: 2px; font-size: 9px; background: rgba(0,0,0,.7); padding: 1px 3px; border-radius: 3px; color: #fff; }
.lib-info { flex: 1; min-width: 0; }
.lib-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-dur  { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.timeline-panel { display: flex; flex-direction: column; overflow: hidden; }
.timeline-info { padding: 9px 16px; background: var(--bg3); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.timeline-track { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-height: 80px; }
.tl-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 28px; color: var(--muted); font-size: 13px; gap: 10px; border: 2px dashed var(--border); border-radius: 12px; }
.tl-empty i { font-size: 36px; }
.tl-item { display: flex; align-items: center; gap: 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; transition: border-color .15s; }
.tl-item:hover { border-color: var(--primary); }
.tl-handle { color: var(--muted); cursor: grab; font-size: 13px; flex-shrink: 0; padding: 2px; }
.tl-handle:active { cursor: grabbing; }
.tl-thumb { width: 54px; height: 34px; flex-shrink: 0; border-radius: 6px; overflow: hidden; background: var(--bg); }
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tl-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.tl-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 165px; }
.tl-duration { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.tl-duration label { font-size: 10px; color: var(--muted); }
.dur-input { width: 66px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 4px 6px; font-size: 12px; text-align: right; }
.dur-input:focus { outline: none; border-color: var(--primary); }
.tl-remove { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 13px; flex-shrink: 0; }
.tl-remove:hover { background: var(--red); color: #fff; }

/* Reports */
.report-filters { padding: 13px 16px; }
.filter-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filter-form .field { margin: 0; min-width: 140px; }
.bar-mini { height: 5px; background: var(--bg3); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar-mini div { height: 100%; background: var(--primary); border-radius: 999px; }

/* Misc */
.url-box { display: flex; align-items: center; gap: 11px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 9px 13px; }
.url-box code { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg2); border: 1px solid var(--border); color: var(--text); padding: 11px 20px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); z-index: 999; transition: opacity .3s, transform .3s; }
.toast.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }
.empty-msg { text-align: center; color: var(--muted); padding: 32px; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 18px; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; margin-top: 14px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 500; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 420px; box-shadow: var(--shadow); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 18px; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .timeline-layout { grid-template-columns: 245px 1fr; }
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .timeline-layout { grid-template-columns: 1fr; height: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  :root { --sidebar-w: 58px; }
  .sidebar-brand { padding: 7px; }
  .sidebar-brand img { max-width: 34px; max-height: 34px; }
  .nav-item span, .footer-user span, .sidebar-dev span { display: none; }
  .nav-item { justify-content: center; padding: 9px; }
  .nav-item i { width: auto; }
  .sidebar-dev a { justify-content: center; }
  .sidebar-dev img { max-width: 26px; max-height: 26px; }
}
