/* ==========================================================================
   OFFICE DESK MANAGER - ENTERPRISE EDITION
   Design System: Enterprise Tech Standard (IBM Carbon / SAP Fiori Horizon / Oracle Redwood)
   ========================================================================== */

:root {
  /* Core Palette */
  --bg-app: #0b0e14;
  --bg-sidebar: #11161f;
  --bg-header: #11161f;
  --bg-card: #161c26;
  --bg-card-hover: #1c2430;
  --bg-elevated: #1e2634;
  --bg-input: #0e1218;

  /* Borders & Dividers */
  --border-subtle: #232c3b;
  --border-strong: #303d52;
  --border-focus: #0f62fe;

  /* Brand & Accents (IBM / SAP Enterprise Blue) */
  --primary: #0f62fe;
  --primary-hover: #0043ce;
  --primary-active: #002d9c;
  --primary-subtle: rgba(15, 98, 254, 0.12);
  --primary-text: #ffffff;

  /* State Colors (Enterprise Semantics) */
  --success: #24a148;
  --success-subtle: rgba(36, 161, 72, 0.12);
  --success-text: #42be65;

  --warning: #f1c21b;
  --warning-subtle: rgba(241, 194, 27, 0.12);
  --warning-text: #fddc69;

  --danger: #da1e28;
  --danger-hover: #ba1b23;
  --danger-subtle: rgba(218, 30, 40, 0.12);
  --danger-text: #ff8389;

  --info: #0043ce;
  --info-subtle: rgba(0, 67, 206, 0.12);

  --purple: #8a3ffc;
  --purple-subtle: rgba(138, 63, 252, 0.12);

  /* Typography */
  --text-primary: #f4f4f4;
  --text-secondary: #c1c7cd;
  --text-muted: #878d96;
  --text-disabled: #525252;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Elevation & Geometry */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);

  --transition-fast: 0.15s cubic-bezier(0.2, 0, 0.38, 0.9);
}

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

/* Material Symbols Integration */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  flex-shrink: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Custom Enterprise Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   APP SHELL LAYOUT (Header + Sidebar + Main Workspace)
   ========================================================================== */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Global Header (Shell Bar) */
.shell-header {
  height: 54px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary), #002d9c);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.5px;
  box-shadow: 0 0 10px rgba(15, 98, 254, 0.35);
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.brand-text span {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  font-weight: 600;
}

.system-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid rgba(36, 161, 72, 0.25);
}

.system-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

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

.server-node-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.server-node-tag span {
  color: var(--primary);
  font-weight: 600;
}

/* Shell Body (Sidebar + Content) */
.shell-body {
  display: flex;
  flex: 1;
}

/* Sidebar Navigation */
.shell-sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex-shrink: 0;
}

.sidebar-category {
  padding: 6px 18px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-muted);
}

.nav-menu {
  list-style: none;
  margin-bottom: 14px;
}

.nav-item-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  position: relative;
}

.nav-item-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
}

.nav-item-btn.active {
  color: #ffffff;
  font-weight: 600;
  background: var(--bg-elevated);
}

.nav-item-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item-btn.active .nav-icon {
  color: var(--primary);
}

.nav-badge-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--border-subtle);
  color: var(--text-secondary);
}

/* Main Workspace */
.shell-main {
  flex: 1;
  background: var(--bg-app);
  padding: 24px 32px 48px;
  overflow-y: auto;
}

/* ==========================================================================
   KPI SCORECARD METRICS TILES
   ========================================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  position: relative;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.kpi-tile:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

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

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

.kpi-icon-pill {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
  font-feature-settings: "tnum";
}

.kpi-footer {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   DATA PANELS & CONTAINERS
   ========================================================================== */

.panel-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-heading h2 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-heading p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Table Toolbar (Search, Filter, Actions) */
.table-toolbar {
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-search {
  position: relative;
  width: 280px;
}

.toolbar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 10px 6px 30px;
  transition: border-color var(--transition-fast);
}

.toolbar-search input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.toolbar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

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

/* Enterprise Data Grid */
.table-wrapper {
  overflow-x: auto;
}

.enterprise-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.enterprise-table th {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.enterprise-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.enterprise-table tbody tr {
  transition: background var(--transition-fast);
}

.enterprise-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* Device Cell Identity */
.device-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}

.device-name {
  font-weight: 600;
  color: #ffffff;
  display: block;
}

.device-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Battery Indicator Bar */
.battery-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.battery-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.battery-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.bat-high { background: var(--success); }
.bat-mid { background: var(--warning); }
.bat-low { background: var(--danger); }

.battery-label {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Status Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.chip-online {
  background: var(--success-subtle);
  color: var(--success-text);
  border-color: rgba(36, 161, 72, 0.25);
}

.chip-offline {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border-color: rgba(218, 30, 40, 0.25);
}

.chip-neutral {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ==========================================================================
   BUTTONS & CONTROLS (Carbon Enterprise Spec)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary:active {
  background: var(--primary-active);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border-color: rgba(218, 30, 40, 0.3);
}
.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-warning {
  background: var(--warning-subtle);
  color: var(--warning-text);
  border-color: rgba(241, 194, 27, 0.3);
}
.btn-warning:hover {
  background: var(--warning);
  color: #111111;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: #ffffff;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-group {
  display: inline-flex;
  gap: 4px;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 12px;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23878d96' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.checkbox-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--text-primary);
}

.checkbox-control input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ==========================================================================
   2-COLUMN WORKSPACE GRIDS
   ========================================================================== */

.workspace-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .workspace-2col {
    grid-template-columns: 1fr;
  }
}

/* Dropzone & Preview Box */
.enterprise-dropzone {
  border: 1px dashed var(--border-strong);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.enterprise-dropzone:hover {
  border-color: var(--primary);
  background: rgba(15, 98, 254, 0.04);
}

.preview-screen {
  background: #000;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-screen img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   MODAL WINDOW (Enterprise Centered Dialog)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-backdrop.active {
  display: flex;
}

.enterprise-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-enter 0.18s ease forwards;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-head {
  background: var(--bg-sidebar);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.modal-body {
  padding: 20px;
}

.modal-foot {
  background: var(--bg-sidebar);
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ==========================================================================
   TOAST NOTIFICATION LEDGER
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast-msg {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  animation: toast-slide 0.2s ease forwards;
}

.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

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