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

:root {
  --color-primary:   #4F6EF7;
  --color-secondary: #3A56D4;
  --color-accent:    #F59E0B;
  --color-bg:        #F4F6FB;
  --color-sidebar:   #1a1f2e;
  --color-text:      #1E293B;
  --font-family:     'Inter', system-ui, sans-serif;

  --sidebar-w:       220px;
  --topbar-h:        56px;
  --radius-sm:       6px;
  --radius:          10px;
  --radius-lg:       14px;

  --color-border:    #E2E8F0;
  --color-muted:     #64748B;
  --color-bg-card:   #FFFFFF;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
}

[data-theme="dark"] {
  --color-bg:      #0f1117;
  --color-bg-card: #1a1f2e;
  --color-text:    #E2E8F0;
  --color-border:  #2d3748;
  --color-muted:   #94A3B8;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }

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

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.sidebar-brand-name {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.sidebar-brand-sub {
  color: rgba(255,255,255,.35);
  font-size: 11px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.nav-section-title {
  display: block;
  color: rgba(255,255,255,.28);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 8px;
  margin: 10px 0 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: 13px;
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 1px;
}

.nav-link:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}

.nav-link.active {
  background: var(--color-primary);
  color: #fff;
}

.nav-link .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: .85;
}

.nav-link.active .nav-icon { opacity: 1; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-name {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: rgba(255,255,255,.35);
  font-size: 11px;
}

/* ── MAIN WRAPPER ─────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.search-wrap {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  color: var(--color-text);
  outline: none;
  transition: border .2s, box-shadow .2s;
  font-family: var(--font-family);
}

.search-wrap input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}

.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 300;
  overflow: hidden;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  font-size: 13px;
  color: var(--color-text);
}

.search-result-item:hover { background: var(--color-bg); }

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

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-muted);
  font-size: 16px;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}

.topbar-icon-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  overflow: hidden;
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: border-color .15s;
}

.topbar-avatar:hover { border-color: var(--color-primary); }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Company switcher */
.company-switcher { position: relative; }
.company-switcher-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text);
  font-family: var(--font-family);
  transition: background .15s;
}
.company-switcher-btn:hover { background: var(--color-border); }

.company-switcher-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}

.company-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--color-text);
  font-family: var(--font-family);
  transition: background .15s;
}

.company-switcher-item:hover { background: var(--color-bg); }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.4;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--color-secondary); border-color: var(--color-secondary); }

.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: #EF4444; color: #fff; border-color: #EF4444; }
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
  font-family: var(--font-family);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}

.form-control::placeholder { color: var(--color-muted); }

textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
}

.badge-secondary { background: var(--color-bg); color: var(--color-muted); border: 1px solid var(--color-border); }
.badge-success   { background: #DCFCE7; color: #16A34A; }
.badge-warning   { background: #FEF9C3; color: #A16207; }
.badge-danger    { background: #FEE2E2; color: #DC2626; }

/* ── NEWS ─────────────────────────────────────────────────── */
.news-hero {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  min-height: 160px;
  background: linear-gradient(135deg, #1a2744, #2d4a8a);
  display: flex;
  align-items: flex-end;
}

.news-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .6;
}

.news-hero-body {
  position: relative;
  z-index: 1;
  padding: 20px;
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 100%);
}

.news-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: box-shadow .15s, transform .15s;
  margin-bottom: 8px;
}

.news-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.news-item-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.news-item-cover {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.news-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-item-meta {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 3px;
}

/* News grid (página de notícias) */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.news-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}

.news-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.news-card-img { width: 100%; height: 160px; object-fit: cover; display: block; }
.news-card-body { padding: 14px 16px; }
.news-card-title { font-size: 15px; font-weight: 600; margin: 6px 0 6px; line-height: 1.4; }
.news-card-title a { color: var(--color-text); text-decoration: none; }
.news-card-title a:hover { color: var(--color-primary); }
.news-card-summary { font-size: 13px; color: var(--color-muted); line-height: 1.5; margin-bottom: 10px; }
.news-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--color-muted); }

/* ── AVATAR ───────────────────────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

/* ── ALERTS ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  margin-bottom: 12px;
}

.alert-info    { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.alert-success { background: #F0FDF4; color: #16A34A; border-color: #BBF7D0; }
.alert-warning { background: #FFFBEB; color: #A16207; border-color: #FDE68A; }
.alert-danger  { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--color-bg); }

/* ── PAGINATION ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; margin-top: 20px; }
.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  text-decoration: none;
  transition: all .15s;
}

.page-link:hover, .page-link.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
}

.empty-state p { font-size: 14px; margin: 0; }

/* ── TABS ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); }
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font-family);
  transition: color .15s;
  text-decoration: none;
}

.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── CALENDAR ─────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day {
  min-height: 64px;
  padding: 5px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-card);
  font-size: 12px;
}

.cal-day.today { background: var(--color-primary); }
.cal-day.today .cal-day-num { color: #fff; font-weight: 700; }
.cal-day-num { font-size: 12px; font-weight: 500; color: var(--color-text); margin-bottom: 3px; }
.cal-event {
  font-size: 10px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 400;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .menu-toggle { display: flex; }

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

  .sidebar-overlay.open { display: block; }

  .main-content { padding: 20px 16px 32px; }
  .topbar { padding: 0 16px; }
  .news-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar .search-wrap { max-width: 200px; }
}
