/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:      #0055FF;
  --brand-dark: #003DC4;
  --brand-light:#E8EFFF;
  --success:    #16A34A;
  --warning:    #D97706;
  --danger:     #DC2626;
  --gray-50:    #F9FAFB;
  --gray-100:   #F3F4F6;
  --gray-200:   #E5E7EB;
  --gray-400:   #9CA3AF;
  --gray-600:   #4B5563;
  --gray-800:   #1F2937;
  --gray-900:   #111827;
  --surface:    #ffffff;
  --input-bg:   #ffffff;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 25px rgba(0,0,0,.12);
}

/* ── Dark Mode ── */
html[data-theme="dark"] {
  --brand:      #4D8CFF;
  --brand-dark: #3378FF;
  --brand-light:#1a2d4a;
  --gray-50:    #0F172A;
  --gray-100:   #1E293B;
  --gray-200:   #334155;
  --gray-400:   #64748B;
  --gray-600:   #CBD5E1;
  --gray-800:   #E2E8F0;
  --gray-900:   #F1F5F9;
  --surface:    #1E293B;
  --input-bg:   #0F172A;
  --shadow:     0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:  0 10px 25px rgba(0,0,0,.5);
}

html[data-theme="dark"] body { background: #0F172A; }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .tasks-container,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .modal { background: var(--surface); border-color: var(--gray-200); }
html[data-theme="dark"] .sidebar { border-right-color: var(--gray-200); }
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .filter-select,
html[data-theme="dark"] .search-input { background: var(--input-bg); color: var(--gray-800); border-color: var(--gray-200); }
html[data-theme="dark"] .tasks-table tr:hover td { background: rgba(255,255,255,.04); }
html[data-theme="dark"] .tasks-table td { border-bottom-color: var(--gray-200); }
html[data-theme="dark"] .btn-ghost { background: var(--gray-100); color: var(--gray-800); }
html[data-theme="dark"] .btn-ghost:hover { background: var(--gray-200); }
html[data-theme="dark"] .badge-pendente  { background: rgba(217,119,6,.2);  color: #FCD34D; }
html[data-theme="dark"] .badge-andamento { background: rgba(37,99,235,.2);   color: #93C5FD; }
html[data-theme="dark"] .badge-concluida { background: rgba(22,163,74,.2);   color: #86EFAC; }
html[data-theme="dark"] .badge-alta      { background: rgba(220,38,38,.2);   color: #FCA5A5; }
html[data-theme="dark"] .badge-media     { background: rgba(217,119,6,.2);   color: #FCD34D; }
html[data-theme="dark"] .badge-baixa     { background: rgba(22,163,74,.2);   color: #86EFAC; }
html[data-theme="dark"] .badge-dono      { background: rgba(124,58,237,.2);  color: #C4B5FD; }
html[data-theme="dark"] .badge-admin     { background: rgba(37,99,235,.2);   color: #93C5FD; }
html[data-theme="dark"] .badge-colab     { background: var(--gray-200);       color: var(--gray-600); }
html[data-theme="dark"] .login-page      { background: linear-gradient(135deg,#0a1628 0%,#0c2454 50%,#0d3278 100%); }
html[data-theme="dark"] .tabs            { border-bottom-color: var(--gray-200); }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0036A3 0%, #0055FF 50%, #3378FF 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 52px; margin-bottom: .75rem; }
.login-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.login-logo p  { font-size: .85rem; color: var(--gray-400); margin-top: .25rem; }

.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--gray-400);
  font-size: .8rem;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-600); margin-bottom: .4rem; }
.form-group input { width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--gray-200); border-radius: var(--radius); font-size: .95rem; transition: border-color .15s; outline: none; background: var(--input-bg); color: var(--gray-800); }
.form-group input:focus { border-color: var(--brand); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, opacity .15s;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost   { background: var(--gray-100); color: var(--gray-800); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-google  { background: var(--surface); color: var(--gray-800); border: 1.5px solid var(--gray-200); }
.btn-google:hover { background: var(--gray-50); }
.btn-sm      { padding: .4rem .8rem; font-size: .8rem; }
.btn-full    { width: 100%; }

.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; display: none; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; display:none; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; display:none; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo { padding: 1.5rem 1.25rem 1rem; border-bottom: 1px solid var(--gray-200); }
.sidebar-logo .agency-name { font-size: 1rem; font-weight: 800; color: var(--brand); letter-spacing: -.01em; }
.sidebar-logo .tagline { font-size: .72rem; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 1rem .75rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .85rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: .15rem;
  transition: background .12s, color .12s;
}
.nav-item:hover, .nav-item.active { background: var(--brand-light); color: var(--brand); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 1rem .75rem; border-top: 1px solid var(--gray-200); }

/* Theme Toggle */
.theme-toggle {
  display: flex;
  gap: .25rem;
  background: var(--gray-100);
  border-radius: 8px;
  padding: .25rem;
  margin-bottom: .75rem;
}

.theme-btn {
  flex: 1;
  background: none;
  border: none;
  padding: .35rem;
  border-radius: 6px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.theme-btn:hover { color: var(--gray-800); }
.theme-btn.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.user-info { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar.has-img { background: none; }

/* Avatar em tabela */
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm.has-img { background: none; }

/* Upload de foto */
.avatar-upload { display: flex; align-items: center; gap: 1rem; }
.avatar-preview { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview.has-img { background: none; }
.avatar-upload-actions { display: flex; flex-direction: column; gap: .4rem; }
.user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; color: var(--gray-400); }

/* Main */
.main-content { margin-left: 240px; flex: 1; padding: 2rem; min-width: 0; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem; }
.page-title  { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: .85rem; color: var(--gray-400); margin-top: .15rem; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); border-left: 4px solid transparent; }
.stat-card.pendente  { border-color: var(--warning); }
.stat-card.andamento { border-color: var(--brand); }
.stat-card.concluida { border-color: var(--success); }
.stat-card.total     { border-color: var(--gray-400); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; margin-bottom: .25rem; }
.stat-label { font-size: .78rem; color: var(--gray-400); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* Filtros */
.filters { display: flex; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.filter-select { padding: .45rem .8rem; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .85rem; color: var(--gray-800); background: var(--surface); outline: none; cursor: pointer; }
.filter-select:focus { border-color: var(--brand); }
.search-input { flex: 1; min-width: 200px; padding: .45rem .85rem; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .85rem; outline: none; background: var(--surface); color: var(--gray-800); }
.search-input:focus { border-color: var(--brand); }

/* Tabela */
.tasks-container { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.tasks-table { width: 100%; border-collapse: collapse; }
.tasks-table th { text-align: left; padding: .75rem 1rem; font-size: .78rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.tasks-table td { padding: .9rem 1rem; font-size: .875rem; vertical-align: middle; border-bottom: 1px solid var(--gray-100); }
.tasks-table tr:last-child td { border-bottom: none; }
.tasks-table tr:hover td { background: var(--gray-50); }
.task-title { font-weight: 600; color: var(--gray-900); margin-bottom: .15rem; }
.task-desc  { font-size: .8rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 20px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-pendente  { background: #FEF3C7; color: #92400E; }
.badge-andamento { background: #DBEAFE; color: #1E40AF; }
.badge-concluida { background: #DCFCE7; color: #166534; }
.badge-alta   { background: #FEE2E2; color: #991B1B; }
.badge-media  { background: #FEF3C7; color: #92400E; }
.badge-baixa  { background: #F0FDF4; color: #166534; }
.badge-dono   { background: #EDE9FE; color: #5B21B6; }
.badge-admin  { background: #DBEAFE; color: #1E40AF; }
.badge-colab  { background: var(--gray-100); color: var(--gray-600); }
.badge-setor  { background: var(--brand-light); color: var(--brand); }

.actions { display: flex; gap: .3rem; flex-wrap: nowrap; align-items: center; }

/* Botões de ação em ícone (padronizado para todos os cargos) */
.btn-icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--gray-200);
  background: var(--surface);
  color: var(--gray-600);
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.btn-icon.success:hover { background: rgba(22,163,74,.12); color: var(--success); border-color: var(--success); }
.btn-icon.danger:hover  { background: rgba(220,38,38,.12);  color: var(--danger);  border-color: var(--danger); }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-400); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: .75rem; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 500px; box-shadow: var(--shadow-lg); transform: translateY(12px); transition: transform .2s; }
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-200); }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--gray-400); font-size: 1.4rem; line-height: 1; padding: .1rem .3rem; border-radius: 6px; transition: background .12s; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.5rem; }
.tab-btn { padding: .6rem 1.1rem; background: none; border: none; font-size: .875rem; font-weight: 600; color: var(--gray-400); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .12s, border-color .12s; }
.tab-btn.active { color: var(--brand); border-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sections */
.page-section { display: none; }
.page-section.active { display: block; }

/* Spinner */
.spinner { width: 22px; height: 22px; border: 3px solid var(--gray-200); border-top-color: var(--brand); border-radius: 50%; animation: spin .6s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Prazo vencido */
.overdue { color: var(--danger); font-weight: 600; }

/* Sync indicator */
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; margin-left: .4rem; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Hamburger */
.hamburger {
  display: none;
  position: fixed;
  top: .9rem; left: .9rem;
  z-index: 150;
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: .4rem .5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.hamburger svg { display: block; }

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

/* Responsive */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; }
  .sidebar-overlay.open { display: block; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 110;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 3.5rem;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }

  .filters { gap: .5rem; }
  .filter-select, .search-input { font-size: .82rem; }

  /* Tabela scroll horizontal */
  .tasks-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tasks-table { min-width: 640px; }
  .tasks-table th, .tasks-table td { padding: .7rem .75rem; }
  .task-desc { max-width: 160px; }

  /* Modal full-width em mobile */
  .modal-backdrop { padding: .5rem; align-items: flex-end; }
  .modal { border-radius: 14px 14px 0 0; max-width: 100% !important; }
}
