/* ============================================================
   app.css — Sistema de Ordem de Serviço
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --primary:       #1E5FA8;
  --primary-dark:  #164d8a;
  --primary-light: #e8f0fb;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --purple:        #6366F1;
  --dark:          #1a1a2e;
  --dark-2:        #16213e;
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active:#1E5FA8;
  --muted:         #64748b;
  --border:        #e2e8f0;
  --bg:            #f8fafc;
  --card-bg:       #ffffff;
  --text:          #1e293b;
  --text-light:    #64748b;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ── Layout geral ──────────────────────────────────────────── */
body:not(.login-body) {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-logo img { width: 32px; height: 32px; object-fit: contain; }
.sidebar-nome {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 14px;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i      { font-size: 18px; width: 20px; text-align: center; }

.nav-divisor {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 16px 12px 6px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.sidebar-user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-user-nome  { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-perfil { font-size: 11px; color: var(--sidebar-text); text-transform: capitalize; }

.btn-logout {
  color: var(--sidebar-text);
  font-size: 18px;
  padding: 6px;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.btn-menu {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--text); padding: 4px;
}
.topbar-titulo { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.topbar-acoes  { display: flex; gap: 8px; }

/* ── Page content ───────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

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

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon--azul   { background: #dbeafe; color: #1d4ed8; }
.stat-icon--verde  { background: #d1fae5; color: #065f46; }
.stat-icon--laranja{ background: #fef3c7; color: #92400e; }
.stat-icon--roxo   { background: #ede9fe; color: #5b21b6; }

.stat-info { display: flex; flex-direction: column; }
.stat-valor { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ── Ações rápidas ──────────────────────────────────────────── */
.acoes-rapidas {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.acao-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
}
.acao-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); color: var(--primary); }
.acao-card--primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.acao-card--primary:hover { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); box-shadow: var(--shadow-md); }
.acao-card i { font-size: 18px; }

/* ── Section header ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-titulo { font-size: 16px; font-weight: 600; color: var(--text); }

/* ── Table card ─────────────────────────────────────────────── */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}
.tabela { width: 100%; border-collapse: collapse; }
.tabela th {
  background: #f8fafc;
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.tabela td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: none; }
.tr-clicavel { cursor: pointer; transition: background .1s; }
.tr-clicavel:hover { background: var(--primary-light); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-agendada  { background: #fef3c7; color: #92400e; }
.badge-execucao  { background: #dbeafe; color: #1d4ed8; }
.badge-revisao   { background: #ede9fe; color: #5b21b6; }
.badge-concluida { background: #d1fae5; color: #065f46; }
.badge-cancelada { background: #fee2e2; color: #991b1b; }

.codigo-publico {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: .05em;
}

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Flash ──────────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin: 0;
  font-size: 14px;
}
.flash button { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .6; font-size: 16px; }
.flash-sucesso { background: #d1fae5; color: #065f46; border-bottom: 1px solid #6ee7b7; }
.flash-erro    { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fca5a5; }
.flash-aviso   { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; }

/* ── Formulários ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-icon { position: relative; }
.input-icon > i:first-child {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}
.input-icon input { padding-left: 38px; }
.btn-toggle-senha {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--muted);
  font-size: 16px; padding: 2px;
}

/* ── Login ──────────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo   { width: 64px; height: 64px; object-fit: contain; margin-bottom: 12px; }
.login-titulo { font-size: 22px; font-weight: 700; color: var(--text); }
.login-sub    { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.login-form .btn { margin-top: 8px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}
.empty-state i    { font-size: 48px; display: block; margin-bottom: 12px; opacity: .4; }
.empty-state p    { margin-bottom: 16px; }

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.aberta {
    transform: translateX(0);
  }
  .sidebar-overlay.visivel {
    display: block;
  }
  .main-content {
    margin-left: 0;
  }
  .btn-menu {
    display: flex;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .page-content {
    padding: 16px;
  }
  .tabela th:nth-child(4),
  .tabela td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 14px; }
  .stat-valor { font-size: 22px; }
  .acoes-rapidas { gap: 8px; }
  .acao-card  { padding: 10px 14px; font-size: 13px; }
}
