/* ==========================================================================
   rotis Industrial Energy Intelligence Platform — Base Styles (app-base.css)
   Pristine Light SCADA/Dashboard Theme for Enterprise Cold Storage
   ========================================================================== */

:root {
  /* Colors */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-alt: #F1F5F9;
  --bg-surface-elevated: #FFFFFF;
  
  --border-subtle: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-focus: #3B82F6;
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-dim: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Brand Accents */
  --brand-primary: #2563EB;
  --brand-primary-hover: #1D4ED8;
  --brand-primary-subtle: #EFF6FF;
  --brand-primary-border: #BFDBFE;

  --accent-cyan: #0284C7;
  --accent-cyan-subtle: #E0F2FE;

  --status-success: #10B981;
  --status-success-subtle: #ECFDF5;
  --status-success-border: #A7F3D0;

  --status-warning: #F59E0B;
  --status-warning-subtle: #FFFBEB;
  --status-warning-border: #FDE68A;

  --status-danger: #EF4444;
  --status-danger-subtle: #FEF2F2;
  --status-danger-border: #FECACA;

  --status-info: #6366F1;
  --status-info-subtle: #EEF2FF;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Dimensions */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
  --header-height: 72px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
}

/* Monospace Metrics */
.metric-value, .mono, [data-mono] {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ==========================================================================
   App Structure Layout
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--bg-app);
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.sidebar-brand img {
  height: 26px;
  width: auto;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--brand-primary-subtle);
  color: var(--brand-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-primary-border);
  letter-spacing: 0.05em;
}

/* Facility Selector Box */
.facility-selector {
  padding: 16px 16px 8px 16px;
}

.facility-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.facility-card:hover {
  border-color: var(--brand-primary-border);
  background: #F8FAFC;
}

.facility-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.facility-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.facility-status {
  font-size: 11px;
  color: var(--status-success);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 10px 6px 10px;
  letter-spacing: 0.05em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-surface-alt);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--brand-primary-subtle);
  color: var(--brand-primary);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-alt);
  color: var(--text-muted);
}

.nav-badge.alert {
  background: var(--status-danger-subtle);
  color: var(--status-danger);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.user-profile-card:hover {
  background: var(--bg-surface-alt);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #E2E8F0;
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 11px;
  color: var(--brand-primary);
  display: inline-block;
  font-weight: 500;
}

/* Role Quick Switcher */
.role-pill-selector {
  display: flex;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 2px;
}

.role-btn {
  flex: 1;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-align: center;
  transition: all var(--transition-fast);
}

.role-btn.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Main Content Area & Top Header
   ========================================================================== */

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.page-title-box {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

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

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

/* Live Telemetry Pills in Header */
.telemetry-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.telemetry-pill.tariff-t2 {
  background: #FEF3C7;
  border-color: #FDE68A;
  color: #B45309;
}

.telemetry-pill.tariff-t3 {
  background: #FEE2E2;
  border-color: #FECACA;
  color: #B91C1C;
}

.telemetry-pill.tariff-t1 {
  background: #ECFDF5;
  border-color: #A7F3D0;
  color: #047857;
}

.impulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-success);
  transition: transform 0.1s ease, background 0.1s ease;
}

.impulse-dot.flash {
  transform: scale(1.6);
  background: #059669;
  box-shadow: 0 0 10px #10B981;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.header-btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.header-btn-secondary:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border-strong);
}

.header-btn-primary {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.header-btn-primary:hover {
  background: var(--brand-primary-hover);
}

/* Main Content Body */
.app-content {
  padding: 28px 32px 60px 32px;
  flex: 1;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }
  .sidebar-brand span,
  .facility-info,
  .nav-item span,
  .nav-badge,
  .nav-section-title,
  .user-details,
  .role-pill-selector {
    display: none;
  }
  .app-main {
    margin-left: var(--sidebar-collapsed-width);
  }
  .app-header {
    padding: 0 20px;
  }
  .app-content {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-main {
    margin-left: 0;
  }
}
