/* ==========================================================================
   Tech House do Brasil - ERP Design System (Blue Palette & Submenus)
   ========================================================================== */

:root {
  /* Tech House Brand Color Palette (Based on Official Logo) */
  --th-blue-dark: #071330;      /* Ultra Deep Navy Header/Sidebar background */
  --th-blue-navy: #0B1957;      /* Brand Deep Navy Blue */
  --th-blue-primary: #1D4ED8;   /* Royal Tech Blue */
  --th-blue-accent: #2563EB;    /* Electric Tech Accent Blue */
  --th-blue-hover: #1E40AF;     /* Hover State Darker Blue */
  --th-blue-light: #3B82F6;     /* Bright Accent */
  --th-cyan-accent: #0284C7;    /* Cyan Highlight */
  --th-blue-soft-bg: #F0F5FF;   /* App Light Background */
  --th-blue-tint: #DBEAFE;      /* Badge Light Blue */
  --th-blue-glow: rgba(37, 99, 235, 0.25);

  /* Neutrals */
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --bg-body: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --border-color: #E2E8F0;
  --border-hover: #BFDBFE;

  /* Status Colors */
  --color-success: #10B981;
  --color-success-bg: #ECFDF5;
  --color-warning: #F59E0B;
  --color-warning-bg: #FFFBEB;
  --color-danger: #EF4444;
  --color-danger-bg: #FEF2F2;
  --color-info: #0284C7;
  --color-info-bg: #F0F9FF;

  /* Layout & Shadows */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(11, 25, 87, 0.05);
  --shadow-md: 0 4px 12px rgba(11, 25, 87, 0.08);
  --shadow-lg: 0 10px 25px rgba(11, 25, 87, 0.12);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.2);
  --transition-fast: all 0.2s ease-in-out;
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Settings */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 0.95rem;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* --------------------------------------------------------------------------
   1. Sidebar Navigation & Submenus
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--th-blue-dark) 0%, var(--th-blue-navy) 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  transition: var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-badge {
  width: 40px;
  height: 40px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--th-blue-navy);
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #FFFFFF;
}

.logo-subtitle {
  font-size: 0.65rem;
  color: #93C5FD;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}

.nav-section-title {
  padding: 0.75rem 1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #93C5FD;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  color: #CBD5E1;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: var(--transition-fast);
  cursor: pointer;
  min-height: 44px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.nav-item.active {
  background: linear-gradient(90deg, var(--th-blue-primary) 0%, var(--th-blue-accent) 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-glow);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Submenu Styles */
.nav-parent {
  justify-content: space-between;
}

.submenu-arrow {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
}

.nav-parent.open .submenu-arrow {
  transform: rotate(90deg);
}

.nav-submenu {
  display: none;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.nav-submenu.open {
  display: block;
}

.nav-subitem {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  color: #94A3B8;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  transition: var(--transition-fast);
  cursor: pointer;
}

.nav-subitem:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-subitem.active {
  background: rgba(37, 99, 235, 0.2);
  color: #60A5FA;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.15);
}

.system-status-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 8px var(--color-success);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7, 19, 48, 0.5);
  backdrop-filter: blur(4px);
  z-index: 95;
}

/* --------------------------------------------------------------------------
   2. Main Layout Area
   -------------------------------------------------------------------------- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: var(--transition-normal);
}

.topbar {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--th-blue-navy);
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 0.5rem;
}

.topbar-search {
  position: relative;
  width: 320px;
}

.topbar-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  transition: var(--transition-fast);
  color: var(--text-main);
}

.topbar-search input:focus {
  outline: none;
  background-color: #FFFFFF;
  border-color: var(--th-blue-accent);
  box-shadow: 0 0 0 3px var(--th-blue-tint);
}

.topbar-search svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

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

.action-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.action-icon-btn:hover {
  background: var(--th-blue-soft-bg);
  color: var(--th-blue-primary);
  border-color: var(--border-hover);
}

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

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: 40px;
}

.user-profile-pill:hover {
  border-color: var(--th-blue-accent);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--th-blue-navy) 0%, var(--th-blue-accent) 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Page Content Area */
.content-body {
  padding: 2rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--th-blue-navy);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   3. Buttons & Component Utilities
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  min-height: 40px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--th-blue-navy) 0%, var(--th-blue-accent) 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--th-blue-dark) 0%, var(--th-blue-hover) 100%);
  box-shadow: 0 6px 15px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--th-blue-soft-bg);
  border-color: var(--th-blue-accent);
  color: var(--th-blue-primary);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
  min-height: 32px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.725rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--th-blue-tint); color: var(--th-blue-primary); }

/* --------------------------------------------------------------------------
   4. KPI Metric Cards
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--th-blue-accent);
}

.kpi-card.kpi-navy::before { background: var(--th-blue-navy); }
.kpi-card.kpi-cyan::before { background: var(--th-cyan-accent); }
.kpi-card.kpi-success::before { background: var(--color-success); }
.kpi-card.kpi-warning::before { background: var(--color-warning); }

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

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--th-blue-soft-bg);
  color: var(--th-blue-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--th-blue-navy);
  margin-bottom: 0.25rem;
}

.kpi-footer {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.trend-up { color: var(--color-success); font-weight: 600; }
.trend-down { color: var(--color-danger); font-weight: 600; }

/* --------------------------------------------------------------------------
   5. Chart Panels & Main Cards
   -------------------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--th-blue-navy);
}

.card-body {
  padding: 1.5rem;
}

.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
}

/* --------------------------------------------------------------------------
   6. Custom Data Tables & Sort Headers
   -------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  white-space: nowrap;
}

.data-table th {
  background: var(--bg-subtle);
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  transition: var(--transition-fast);
}

.data-table th.sortable:hover {
  background: var(--th-blue-tint);
  color: var(--th-blue-primary);
  cursor: pointer;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: var(--th-blue-soft-bg);
}

.sort-icon {
  font-size: 0.7rem;
  margin-left: 4px;
  color: var(--th-blue-primary);
}

.key-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--bg-subtle);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  color: var(--th-blue-navy);
  border: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   7. Form Controls & Modals
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-main);
  background: #FFFFFF;
  transition: var(--transition-fast);
  min-height: 42px;
}

.form-control:focus {
  outline: none;
  border-color: var(--th-blue-accent);
  box-shadow: 0 0 0 3px var(--th-blue-tint);
}

.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7, 19, 48, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
  padding: 1rem;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: var(--transition-normal);
}

.modal-backdrop.show .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(90deg, var(--th-blue-navy) 0%, var(--th-blue-primary) 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.modal-close:hover {
  color: #FFFFFF;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 90vw;
}

.toast {
  background: var(--th-blue-dark);
  color: #FFFFFF;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  border-left: 4px solid var(--th-blue-accent);
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   8. Mobile Responsive Breakpoints (< 768px & < 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

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

  .main-wrapper {
    margin-left: 0;
  }

  .topbar {
    padding: 0 1rem;
  }

  .topbar-search {
    width: 180px;
  }

  .content-body {
    padding: 1rem;
  }

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

  .btn {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .modal-card {
    max-height: 90vh;
  }

  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}
