/* ===========================================================
   BASE — Reset, tipografía, layout, sidebar
   =========================================================== */

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

body {
  background: var(--bg-base);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  letter-spacing: -0.01em;
  overflow-x: hidden;
  transition: background-color var(--t-slow), color var(--t-slow);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-gradient);
  pointer-events: none;
  z-index: 0;
  transition: opacity var(--t-slow);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  background-clip: content-box;
  transition: background var(--t-base);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
  background-clip: content-box;
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text);
}
h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.035em; font-weight: 700; }
h2 { font-size: 22px; line-height: 1.2;  letter-spacing: -0.025em; font-weight: 700; }
h3 { font-size: 17px; line-height: 1.3;  letter-spacing: -0.018em; }
h4 { font-size: 15px; line-height: 1.4; }

p { margin: 0; line-height: 1.55; }

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
  letter-spacing: -0.005em;
}

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

code, pre, .mono { font-family: var(--font-mono); }

/* ===========================================================
   LAYOUT
   =========================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===========================================================
   SIDEBAR — Translúcida con blur fino
   =========================================================== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
}

.sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.traffic-lights {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.traffic-light {
  width: 11px; height: 11px;
  border-radius: 50%;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15);
}
.traffic-light.close { background: #ff5f57; }
.traffic-light.min   { background: #febc2e; }
.traffic-light.max   { background: #28c840; }
.traffic-lights:hover .traffic-light { transform: scale(1.08); }

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}

.sidebar-section {
  padding: 16px 18px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  margin: 2px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  cursor: pointer;
  letter-spacing: -0.005em;
}
.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.sidebar-item.active {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25),
              inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.sidebar-item.active:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent);
}
.sidebar-item:active {
  transform: scale(0.98);
}
.sidebar-item .icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.sidebar-item.active .icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}
.sidebar-user:hover {
  background: var(--bg-hover);
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  letter-spacing: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: capitalize;
  letter-spacing: -0.005em;
}
.logout-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.logout-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ===========================================================
   MAIN
   =========================================================== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.toolbar {
  height: 48px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-toolbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: var(--z-toolbar);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: -0.005em;
}

.toolbar-title {
  font-weight: 600;
  color: var(--text);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-translucent);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle:active {
  transform: scale(0.94);
}

.content {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1400px;
  width: 100%;
}

/* ===========================================================
   FLASH MESSAGES
   =========================================================== */
.flash-messages {
  position: fixed;
  top: 64px;
  right: 24px;
  z-index: var(--z-flash);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 420px;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-popover);
  min-width: 280px;
  pointer-events: auto;
  animation: flash-in 320ms var(--ease-spring) both;
  letter-spacing: -0.005em;
}
.flash.success { color: var(--success); border-color: rgba(48, 209, 88, 0.28); }
.flash.error   { color: var(--danger);  border-color: rgba(255, 69, 58, 0.28); }
.flash.warning { color: var(--warning); border-color: rgba(255, 159, 10, 0.28); }
.flash.info    { color: var(--accent);  border-color: rgba(10, 132, 255, 0.28); }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-title, .sidebar-section, .sidebar-user-info, .sidebar-item span:not(.icon) {
    display: none;
  }
  .sidebar-item { justify-content: center; padding: 10px; }
  .content { padding: 20px 16px 40px; }
  .toolbar { padding: 0 16px; }
}
