/* ============================================================
   Sistema de Aprovação de Materiais — Design Flat
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 8px rgba(17, 24, 39, .04);
  --shadow-lg: 0 8px 24px rgba(17, 24, 39, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 8px; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Shell / Sidebar ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); flex-shrink: 0; }

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  transition: background .12s ease, color .12s ease;
}

.sidebar-nav a svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.sidebar-nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary-dark); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info small { color: var(--text-soft); font-size: 11px; }

.logout-link { color: var(--text-soft); padding: 6px; border-radius: 6px; }
.logout-link:hover { background: var(--danger-soft); color: var(--danger); }
.logout-link svg { width: 16px; height: 16px; fill: currentColor; display: block; }

.main-content { flex: 1; padding: 28px 36px 60px; max-width: 1280px; }

/* ---------- Flash messages ---------- */

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 600; font-size: 13px; }
.flash-success { background: var(--success-soft); color: #166534; }
.flash-error { background: var(--danger-soft); color: #991b1b; }
.flash-info { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Page header ---------- */

.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header p { color: var(--text-muted); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 13px; cursor: pointer; transition: all .12s ease;
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn:hover { border-color: #d1d5db; background: var(--surface-alt); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }

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

.btn-outline-success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }
.btn-outline-success:hover { background: #dcfce7; }

.btn-outline-danger { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.btn-outline-danger:hover { background: #fee2e2; }

.btn-outline-danger.is-active {
  background: var(--danger); color: #fff; border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}

.card + .card { margin-top: 20px; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }

@media (max-width: 980px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Stat tiles ---------- */

.stat-tile { display: flex; align-items: center; justify-content: space-between; }
.stat-tile .value { font-size: 30px; font-weight: 800; }
.stat-tile .label { color: var(--text-muted); font-weight: 600; font-size: 13px; }
.stat-tile .icon-box {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-tile .icon-box svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-amber { background: var(--warning-soft); color: #92400e; }
.badge-green { background: var(--success-soft); color: #166534; }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge-violet { background: var(--violet-soft); color: #5b21b6; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px; font-weight: 700; color: var(--text-muted); border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Tables / lists ---------- */

.material-list { display: flex; flex-direction: column; gap: 10px; }

.material-row {
  display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); transition: box-shadow .12s ease, border-color .12s ease;
}
.material-row:hover { box-shadow: var(--shadow-lg); border-color: #d1d5db; }

.material-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-alt);
  border: 1px solid var(--border); flex-shrink: 0;
}
.material-thumb-video {
  width: 56px; height: 56px; border-radius: var(--radius-sm); background: #111827; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.material-thumb-video svg { width: 20px; height: 20px; fill: currentColor; }

.material-row-info { flex: 1; min-width: 0; }
.material-row-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-row-info span { color: var(--text-soft); font-size: 12px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-soft); }
.empty-state svg { width: 40px; height: 40px; fill: currentColor; opacity: .4; margin-bottom: 10px; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 13px; }
.form-hint { color: var(--text-soft); font-size: 12px; margin-top: 4px; }

.input, textarea.input, select.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.input:focus, textarea.input:focus, select.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.checkbox-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 13px;
}
.checkbox-pill:hover { background: var(--surface-alt); }
.checkbox-pill input { accent-color: var(--primary); }

.file-drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center;
  color: var(--text-muted); cursor: pointer; background: var(--surface-alt);
}
.file-drop:hover { border-color: var(--primary); color: var(--primary-dark); }
.file-drop svg { width: 30px; height: 30px; fill: currentColor; opacity: .5; margin-bottom: 8px; }

/* ---------- Material detail / annotation viewer ---------- */

.material-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }

.viewer-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; flex-wrap: wrap;
}
.viewer-toolbar .divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.tool-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 12px;
  color: var(--text-muted);
}
.tool-btn svg { width: 16px; height: 16px; fill: currentColor; }
.tool-btn:hover { background: var(--surface-alt); }
.tool-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.color-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }

.viewer-stage {
  position: relative; background: #0b0e14; border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center; min-height: 320px;
}
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 74vh; display: block; }
.viewer-stage canvas { position: absolute; top: 0; left: 0; cursor: crosshair; }
.viewer-stage.pen-mode canvas { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><circle cx='12' cy='12' r='4' fill='%232563eb'/></svg>") 12 12, crosshair; }

.pin-marker {
  position: absolute; width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: translate(-50%, -100%) rotate(-45deg);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 11px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer;
}
.pin-marker span { transform: rotate(45deg); }

.annotation-filter { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.comment-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.comment-item { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.comment-item .avatar { width: 28px; height: 28px; font-size: 12px; }
.comment-item-body { flex: 1; }
.comment-item-body .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.comment-item-body .meta strong { font-size: 13px; }
.comment-item-body .meta time { color: var(--text-soft); font-size: 11px; }
.comment-item-body p { margin: 0; font-size: 13px; color: var(--text); }
.comment-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--surface-alt); color: var(--text-muted); }

.approver-list { display: flex; flex-direction: column; gap: 8px; }
.approver-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-alt); }
.approver-row .avatar { width: 28px; height: 28px; font-size: 12px; }
.approver-row-name { flex: 1; font-weight: 600; font-size: 13px; }

.decision-actions { display: flex; gap: 10px; margin-top: 18px; }
.decision-actions .btn { flex: 1; }

/* ---------- Video timeline ---------- */

.video-timeline { margin-top: 12px; }
.timeline-track {
  position: relative; height: 34px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; overflow: visible;
}
.timeline-progress {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%; background: var(--primary-soft);
  border-radius: 999px 0 0 999px; pointer-events: none;
}
.timeline-marker {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff;
  transform: translate(-50%, -50%); cursor: pointer; box-shadow: 0 1px 3px rgba(17,24,39,.3); z-index: 2;
}
.timeline-range {
  position: absolute; top: 50%; height: 10px; transform: translateY(-50%); border-radius: 999px;
  opacity: .35; cursor: pointer; z-index: 1; min-width: 4px;
}
.timeline-marker:hover { transform: translate(-50%, -50%) scale(1.25); }
.timeline-marker.is-pin { border-radius: 4px; }
.timeline-time {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; font-weight: 700;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}

.comment-item-seekable { cursor: pointer; }
.comment-item-seekable:hover { border-color: var(--primary); background: var(--primary-soft); }
.comment-tag-time { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Calendar ---------- */

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-nav { display: flex; gap: 6px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-weekday { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; padding-bottom: 6px; }
.calendar-day {
  min-height: 110px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px;
  background: var(--surface); display: flex; flex-direction: column; gap: 6px;
}
.calendar-day.is-outside { background: var(--surface-alt); opacity: .5; }
.calendar-day.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.calendar-day .day-number { font-weight: 700; font-size: 12px; color: var(--text-muted); }
.calendar-chip {
  font-size: 10.5px; font-weight: 700; padding: 3px 6px; border-radius: 5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: block;
}
.calendar-legend { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.calendar-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Popup de anotação (pin/desenho) ---------- */

.pin-popup {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 200;
  width: 240px;
}
.pin-popup.pin-popup-wide { width: 280px; }

.pin-highlight-ring {
  position: absolute; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 3px var(--primary), 0 2px 10px rgba(17,24,39,.4);
  transform: translate(-50%, -100%) translateY(-4px);
  pointer-events: none; display: none; animation: pin-pulse 1s ease-in-out infinite;
}
@keyframes pin-pulse {
  0%, 100% { transform: translate(-50%, -100%) translateY(-4px) scale(1); }
  50% { transform: translate(-50%, -100%) translateY(-4px) scale(1.15); }
}

.timeline-marker.is-highlighted {
  transform: translate(-50%, -50%) scale(1.5);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .35), 0 1px 3px rgba(17,24,39,.3);
}
.pin-marker.is-highlighted {
  animation: pin-pulse-marker 1s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .45), 0 2px 6px rgba(0,0,0,.35);
}
@keyframes pin-pulse-marker {
  0%, 100% { transform: translate(-50%, -100%) rotate(-45deg) scale(1); }
  50% { transform: translate(-50%, -100%) rotate(-45deg) scale(1.2); }
}

/* ---------- Prévia flutuante do calendário ---------- */

#calendar-hover-preview {
  position: fixed; z-index: 300; width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; pointer-events: none; display: none; overflow: hidden;
}
#calendar-hover-preview.open { display: block; }
#calendar-hover-preview img, #calendar-hover-preview video {
  width: 100%; max-height: 160px; object-fit: cover; border-radius: 6px; display: block; background: #0b0e14;
}
.calendar-hover-preview-title {
  font-size: 12px; font-weight: 700; padding: 6px 2px 2px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .5); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

/* ---------- Login ---------- */

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; margin-bottom: 24px; }

/* ---------- Utility ---------- */

.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
