/* portal.css — v1.00 */
/* Slotcar Engineering Portal — dark/light theme via CSS variables */

:root, [data-theme="dark"] {
  --bg-primary:    #0f1117;
  --bg-secondary:  #1a1d27;
  --bg-card:       #21253a;
  --bg-sidebar:    #161925;
  --border:        #2e3250;
  --text-primary:  #e8eaf0;
  --text-secondary:#9096b0;
  --text-muted:    #5a6080;
  --accent:        #4f8ef7;
  --accent-hover:  #3a7ae8;
  --accent-dim:    rgba(79,142,247,0.15);
  --success:       #3ecf8e;
  --warning:       #f5a623;
  --danger:        #e55353;
  --sidebar-width: 220px;
}

[data-theme="light"] {
  --bg-primary:    #f0f2f7;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-sidebar:    #1a1d27;
  --border:        #dde1ed;
  --text-primary:  #1a1d27;
  --text-secondary:#4a5070;
  --text-muted:    #8a90a8;
  --accent:        #3a7ae8;
  --accent-hover:  #2a6ad8;
  --accent-dim:    rgba(58,122,232,0.10);
  --success:       #2eaf78;
  --warning:       #d4861a;
  --danger:        #cc3333;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 24px;
  color: var(--accent);
}

.sidebar-title {
  color: #e8eaf0;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.sidebar-title small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}

.nav-menu {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #9096b0;
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 8px;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--accent-dim); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.nav-divider { border-top: 1px solid var(--border); margin: 8px 16px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 13px;
}

.role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-admin    { background: rgba(229,83,83,0.2);  color: #e55353; }
.role-engineer { background: rgba(79,142,247,0.2); color: #4f8ef7; }
.role-viewer   { background: rgba(90,96,128,0.3);  color: #9096b0; }

.theme-toggle a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 16px;
}
.theme-toggle a:hover { color: var(--accent); }

.logout-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}
.logout-btn:hover { color: var(--danger); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-subtitle { color: var(--text-secondary); margin-top: 4px; }

/* App grid (dashboard) */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.15s;
}

.app-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}

.app-card-icon { font-size: 28px; color: var(--accent); }
.app-card-body { flex: 1; }
.app-card-body h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.app-card-body p { color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.app-card-arrow { color: var(--text-muted); font-size: 18px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--accent-dim); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 120px; }

/* Buttons */
.btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; text-align: center; padding: 11px; }
.btn-sm { padding: 5px 12px; font-size: 12px; background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: rgba(229,83,83,0.15); border: 1px solid rgba(229,83,83,0.3); color: var(--danger); }

/* Status badges */
.badge-active   { color: var(--success); font-size: 12px; }
.badge-inactive { color: var(--text-muted); font-size: 12px; }

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 40px; display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-header p { color: var(--text-muted); font-size: 13px; }

/* Empty state */
.empty-state { color: var(--text-muted); padding: 40px; text-align: center; }

/* Responsive */
@media (max-width: 700px) {
  .sidebar { width: 60px; }
  .sidebar-title, .nav-item span:last-child, .user-info .username,
  .role-badge, .logout-btn { display: none; }
  .main-content { margin-left: 60px; padding: 16px; }
}

/* =====================================================
   Dash Dropdown dark theme overrides
   ===================================================== */
.Select-control,
.Select-menu-outer,
.Select--single > .Select-control .Select-value,
.Select-placeholder,
.Select-input > input {
  background-color: #21253a !important;
  color: #e8eaf0 !important;
  border-color: #2e3250 !important;
}

.Select-menu {
  background-color: #21253a !important;
}

.Select-option {
  background-color: #21253a !important;
  color: #e8eaf0 !important;
}

.Select-option:hover,
.Select-option.is-focused {
  background-color: #2e3250 !important;
  color: #4f8ef7 !important;
}

.Select-option.is-selected {
  background-color: #161925 !important;
  color: #4f8ef7 !important;
}

.Select-arrow-zone .Select-arrow {
  border-top-color: #9096b0 !important;
}

.Select--single .Select-value-label {
  color: #e8eaf0 !important;
}

/* Dash 2.x uses VirtualizedSelect / react-select */
.dash-dropdown .Select-control {
  background-color: #21253a !important;
  border-color: #2e3250 !important;
}

/* react-select v2+ classes used by Dash 2.x */
[class*="-control"] {
  background-color: #21253a !important;
  border-color: #2e3250 !important;
  color: #e8eaf0 !important;
}

[class*="-menu"] {
  background-color: #1a1d27 !important;
  border: 1px solid #2e3250 !important;
  z-index: 9999 !important;
}

[class*="-option"] {
  background-color: #1a1d27 !important;
  color: #e8eaf0 !important;
  cursor: pointer !important;
}

[class*="-option"]:hover,
[class*="-option--is-focused"] {
  background-color: #2e3250 !important;
  color: #4f8ef7 !important;
}

[class*="-option--is-selected"] {
  background-color: #161925 !important;
  color: #4f8ef7 !important;
  font-weight: 600 !important;
}

[class*="-singleValue"] {
  color: #e8eaf0 !important;
}

[class*="-placeholder"] {
  color: #9096b0 !important;
}

[class*="-indicatorSeparator"] {
  background-color: #2e3250 !important;
}

[class*="-dropdownIndicator"] svg {
  fill: #9096b0 !important;
}

[class*="-Input"] input {
  color: #e8eaf0 !important;
}

[class*="-ValueContainer"] {
  background-color: #21253a !important;
}
