/* ==========================================================
   PORTAL TI - DESIGN SYSTEM
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* LIGHT MODE (Default) - Based on Portal-Tecnologia */
  --primary: #f26322;
  --primary-hover: #e5561d;
  --primary-soft: rgba(242, 99, 34, 0.1);
  
  --bg-main: #f6f7fb;
  --bg-sidebar: #111c38;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #c7cfdd;
  
  --border-color: #e2e8f0;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.5);
  
  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  
  /* Radii */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* DARK MODE OVERRIDES */
[data-theme="dark"] {
  --bg-main: #020617;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-sidebar: #64748b;
  
  --border-color: #334155;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

/* RESET & BASE */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

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

/* GLASSMORPHISM */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
}

/* LAYOUT */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR - Dark Blue */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 800;
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
}

.sidebar.collapsed {
  width: 76px;
}

.sidebar.collapsed .nav {
  padding: 1rem 0.5rem;
}

.sidebar.collapsed .nav a {
  justify-content: center;
  padding: 0.75rem;
  gap: 0;
}

.sidebar.collapsed .nav a span {
  display: none;
}

.sidebar.collapsed .nav a.active::before {
  top: 15%;
  height: 70%;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand img {
  height: 48px;
  transition: var(--transition);
}

.sidebar.collapsed .brand img {
  height: 32px;
}

.nav {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-sidebar);
  border-radius: var(--radius-lg);
  font-weight: 500;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}

.nav a i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}

.nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 4px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.nav .hr {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 1rem 0;
}

/* MAIN CONTENT */
.main {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  background: var(--bg-sidebar);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: sticky;
  top: 0;
  z-index: 900;
  height: 64px;
}

.topbar .logo-container {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-right: 1.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  margin-right: 1.5rem;
}

.breadcrumb {
  display: flex;
  flex-direction: column;
  justify-content: center;
  white-space: nowrap;
}

.breadcrumb-path {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 2px;
}

.breadcrumb-path span {
  margin: 0 0.4rem;
  font-size: 0.5rem;
}

.breadcrumb-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.topbar-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.topbar-btn:hover {
  color: var(--primary);
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
}

.notification-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}

/* SIDEBAR TOGGLE CIRCLE */
.sidebar-toggle-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}

.sidebar-toggle-circle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #fff;
}

/* MAIN CONTENT ADJUSTMENT */
.main {
  flex: 1;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}

.main-content-padding {
  padding: 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ELITE CARDS */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

/* DASHBOARD KPI ELITE */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 12px var(--primary-soft);
  transition: var(--transition);
}

.kpi-card:hover .kpi-icon {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 0 20px rgba(242, 99, 34, 0.2);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.kpi-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* BUTTONS ELITE */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(242, 99, 34, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 8px 24px rgba(242, 99, 34, 0.4);
  transform: scale(1.02);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-main);
}

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

/* TABLES ELITE */
.table-container {
  border-radius: var(--radius-2xl);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: rgba(248, 250, 252, 0.5);
  padding: 1.25rem 1.5rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

[data-theme="dark"] .table th {
  background: rgba(15, 23, 42, 0.5);
}

.table td {
  padding: 1.25rem 1.5rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.table tr:hover td {
  background: var(--primary-soft);
}

/* FORMS ELITE */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.625rem;
  color: var(--text-main);
}

.input, select, textarea {
  width: 100%;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: var(--transition);
}

.input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  outline: none;
}

/* BADGES ELITE */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* THEME TOGGLE */
.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--primary-soft);
  color: var(--primary);
  border: none;
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: rotate(45deg) scale(1.1);
}

/* UTILS */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
  animation: fadeIn 0.5s ease-out forwards;
}

/* RESPONSIVE ELITE */
@media (max-width: 1024px) {
  .sidebar { width: 88px; }
  .sidebar .nav a span, .sidebar .brand span { display: none; }
  .main { padding: 1.5rem; }
}

/* Fundo escuro do menu deslizante no celular */
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 999; opacity: 0; visibility: hidden; transition: opacity .3s;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

@media (max-width: 768px) {
  .app-wrapper { height: 100vh; overflow: hidden; }
  .container { flex-direction: row; overflow: hidden; }

  /* Menu vira gaveta deslizante */
  .sidebar, .sidebar.collapsed {
    position: fixed; top: 0; left: 0; height: 100vh;
    width: min(82vw, 300px); transform: translateX(-100%);
    transition: transform .3s ease; z-index: 1000; overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .nav a span, .sidebar .brand span { display: inline !important; }
  .sidebar .nav a {
    justify-content: flex-start !important; gap: .75rem !important;
    padding: .8rem 1rem !important;
  }
  .sidebar .brand img { height: 40px !important; }

  /* Conteúdo ocupa a tela inteira */
  .main { width: 100%; padding: 0; }
  .main-content-padding { padding: 1.1rem 1rem; gap: 1.25rem; }

  /* Barra superior enxuta */
  .topbar { padding: .6rem .9rem; }
  .topbar .logo-container { gap: .6rem; padding-right: .6rem; margin-right: .6rem; }
  .breadcrumb { display: none; }
  .topbar-actions span[title="Usuário conectado"] { display: none; }
  .topbar-divider { display: none; }

  /* Tudo em uma coluna (inclusive grids com estilo embutido) */
  html, body { overflow-x: hidden; max-width: 100%; }
  .cards-grid { grid-template-columns: 1fr; }
  .main-content-padding [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .flex.justify-between { flex-wrap: wrap; gap: .6rem; }
  .flex.justify-between > * { min-width: 0; }
  .main-content-padding p, .main-content-padding h2 { overflow-wrap: anywhere; }
  .card { padding: 1.25rem; }
  .card, .main-content-padding > * { max-width: 100%; }
  /* Tabelas largas rolam lateralmente dentro do card, sem empurrar a página */
  table { min-width: 520px; }
  .table-wrap, .card > div[style*="overflow"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}


