/* === LAYOUT — Monitor Ventas Generales === */

/* === HEADER === */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; padding: 0 var(--sp-6);
  z-index: 1000;
  transition: background var(--t-theme);
}

.header-title {
  font-weight: 700; font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--sp-3);
}

.header-empresa {
  font-size: 13px; color: var(--color-text-muted); font-weight: 500;
}

.connection-status {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--color-text-muted); font-size: 13px;
}

.status-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background-color: #6B7280;
  transition: all var(--t-fast);
}

.status-indicator.connected {
  background-color: var(--color-positive);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.status-indicator.error {
  background-color: var(--color-negative);
}

.header-actions {
  display: flex; align-items: center; gap: 0.75rem;
}

.header-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--t-fast) var(--ease-out);
}
.header-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}
.header-btn:active { transform: scale(0.92); }
.header-btn svg { width: 18px; height: 18px; }
.header-btn.spin-active svg { animation: spin 0.8s linear infinite; }

/* === THEME TOGGLE === */
.theme-toggle {
  width: 52px; height: 28px;
  background: var(--toggle-bg);
  border-radius: var(--r-full);
  position: relative; cursor: pointer;
  transition: background var(--t-theme);
  border: 1px solid var(--color-border);
}

.theme-toggle-knob {
  width: 22px; height: 22px;
  background: var(--toggle-knob);
  border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: transform var(--t-base) var(--ease-spring), background var(--t-theme);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.theme-toggle-knob svg { width: 13px; height: 13px; color: var(--toggle-icon); }
[data-theme="dark"] .theme-toggle-knob { transform: translateX(24px); }

/* === SIDEBAR === */
#sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0;
  width: 220px; background: var(--bg-sidebar);
  border-right: 1px solid var(--color-border);
  padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
  overflow-y: auto; z-index: 900;
  transition: background var(--t-theme), border-color var(--t-theme);
}

.sidebar-nav {
  display: flex; flex-direction: column; gap: 0;
}

.sidebar-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-disabled);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--t-fast) var(--ease-out);
  border-left: 2px solid transparent;
  width: 100%; text-align: left;
  cursor: pointer; user-select: none;
  font-family: var(--font-family);
}
.sidebar-nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-nav-item:hover { background: var(--sidebar-hover-bg); color: var(--color-text-primary); }
.sidebar-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--color-accent);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}

/* === MAIN CONTENT === */
.app-body {
  display: flex;
  min-height: calc(100vh - 56px);
}

main {
  margin-left: 220px; margin-top: 56px;
  padding: var(--sp-8);
  min-height: calc(100vh - 56px);
  transition: margin-left var(--t-slow) var(--ease-out);
  flex: 1;
}

/* === SECTIONS === */
.section-view {
  animation: sectionIn 0.5s var(--ease-out) both;
  width: 100%;
}

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

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-8);
}

.section-header h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--color-text-primary);
}
.section-header h2 i,
.section-header h2 svg {
  width: 22px; height: 22px; color: var(--color-accent);
}

.section-header-actions {
  display: flex; align-items: center; gap: var(--sp-4);
}

/* === LOGIN SCREEN === */
.db-config-section {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; align-items: center;
  background: var(--login-gradient);
  z-index: 1050;
}

.db-config-card {
  background-color: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--r-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 550px;
}

.db-config-header {
  text-align: center; margin-bottom: 2rem;
}

.db-config-icon {
  color: var(--color-accent);
  width: 48px; height: 48px; margin-bottom: 1rem;
}

.db-config-header h2 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
}

.db-config-header p {
  color: var(--color-text-muted); font-size: 1rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .header { padding: 0 var(--sp-4); }

  #sidebar {
    position: fixed; top: 56px; left: 0; right: 0;
    width: 100%; bottom: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--sp-2) var(--sp-3);
    flex-direction: row;
    overflow-x: auto; overflow-y: visible;
    z-index: 850;
  }

  .sidebar-nav { flex-direction: row; }

  .sidebar-nav-item {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: var(--sp-2) var(--sp-3);
  }
  .sidebar-nav-item.active {
    border-left: none;
    border-bottom-color: var(--color-accent);
  }

  .sidebar-label { display: none; }

  main {
    margin-left: 0;
    margin-top: 100px;
    padding: var(--sp-4);
  }

  .app-body { flex-direction: column; }
}

@media (max-width: 640px) {
  .header-empresa { display: none; }
}
