/* ==========================================================================
   DESIGN SYSTEM - SINDICATO DAS TRABALHADORAS E TRABALHADORES PAPELEIROS
   STP Sorocaba, Angatuba e Região • Sistema Integrado Web & Mobile
   ========================================================================== */

:root {
  /* Brand Palette - Papeleiros de Sorocaba */
  --stp-navy: #0b2545;
  --stp-navy-dark: #07172c;
  --stp-blue-primary: #134074;
  --stp-blue-accent: #1d4ed8;
  --stp-blue-light: #e0e7ff;
  --stp-paper-green: #007f5f;
  --stp-paper-green-light: #d8f3dc;
  --stp-red: #c1121f;
  --stp-red-light: #fee2e2;
  --stp-gold: #e0a96d;
  --stp-amber: #f59e0b;
  --stp-amber-light: #fef3c7;
  --pix-cyan: #00b4d8;
  --pix-cyan-glow: rgba(0, 180, 216, 0.35);

  /* Light Theme Defaults */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #0b2545;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-topbar: #ffffff;
  --bg-muted: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;

  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #134074;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s ease;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --bg-card: #131d31;
  --bg-sidebar: #060b14;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-topbar: #0f172a;
  --bg-muted: #1e293b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --border-subtle: #172033;
  --border-focus: #3b82f6;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.7);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

a {
  color: var(--stp-blue-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   APP SHELL LAYOUT (ERP + PORTAL)
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* SIDEBAR (ERP MASTER / DIRETORIA) */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 100;
  transition: all var(--transition-normal);
  position: relative;
}

.sidebar-header {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 100%);
}

.sidebar-logo {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--stp-gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.sidebar-brand-text h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  margin: 0;
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--stp-gold);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.6px;
  display: block;
}

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

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: #64748b;
  padding: 10px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  transition: all var(--transition-fast);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: #94a3b8;
  transition: color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}
.nav-item:hover i {
  color: #ffffff;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--stp-blue-primary), #1e3a8a);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(19, 64, 116, 0.4);
}
.nav-item.active i {
  color: var(--stp-gold);
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.location-indicator {
  font-size: 12px;
  line-height: 1.4;
}

.location-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.location-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stp-gold);
  margin-top: 4px;
  flex-shrink: 0;
}
.location-dot.sorocaba {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* ==========================================================================
   MAIN CONTENT WRAPPER & TOP BAR
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
}

.top-bar {
  height: 72px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.page-title-box h1 {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title-box p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pix-badge-quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--pix-cyan-glow);
  transition: transform var(--transition-fast);
}
.pix-badge-quick:hover {
  transform: translateY(-1px);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--stp-blue-accent);
}

/* User pill in header */
.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-profile-pill:hover {
  transform: translateY(-1px);
  border-color: var(--stp-blue-accent);
}

.user-avatar-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--stp-blue-accent);
}
.user-pill-info {
  line-height: 1.2;
}
.user-pill-name {
  font-size: 13px;
  font-weight: 600;
}
.user-pill-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Role Cards Active State */
.active-role-card {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), var(--shadow-lg) !important;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.03) 0%, var(--bg-card) 100%) !important;
}

/* ==========================================================================
   CONTENT BODY & SPA MODULE VIEWS
   ========================================================================== */
.content-body {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.module-view {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.module-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsiveness */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 100%;
    display: none;
  }
  .sidebar.mobile-open {
    display: flex;
  }
  .top-bar {
    padding: 0 16px;
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .content-body {
    padding: 16px;
  }
}
