/* ==========================================================================
   TOPNOTCH TECH PORTAL STYLES
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-darker);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold-secondary);
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */

.app-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg-dark);
  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-h);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-emblem {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px var(--gold-glow));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.04em;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--gold-secondary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Navigation Links */
.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem 0.75rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.nav-item svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--gold-light);
}

.nav-item:hover svg {
  color: var(--gold-primary);
}

.nav-item.active {
  background-color: rgba(212, 175, 55, 0.12);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--gold-primary);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background-color: var(--gold-primary);
  color: var(--bg-darker);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sidebar-footer);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-gradient);
  color: var(--bg-darker);
  font-weight: 700;
  font-family: var(--font-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

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

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.7rem;
  color: var(--gold-secondary);
  text-transform: capitalize;
}

.logout-link {
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.logout-link:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-darker);
}

/* Top App Header */
.app-header {
  height: var(--header-h);
  background-color: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

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

.header-page-title {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* Content Container */
.app-content {
  flex: 1;
  padding: 2rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

.portal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  transition: border-color var(--transition-normal);
}

.portal-card.hover-lift:hover {
  border-color: var(--gold-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-heading {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* KPI / Metric Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gold-gradient);
  opacity: 0.8;
}

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-family: var(--font-brand);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--gold-secondary);
}

.kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-primary);
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--gold-gradient);
  color: #121416;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 18px rgba(212, 175, 55, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.btn-outline-gold {
  background: transparent;
  border-color: var(--gold-border-bright);
  color: var(--gold-primary);
}

.btn-outline-gold:hover {
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold-light);
}

.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background-color: #DC2626;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.portal-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

.portal-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.portal-table th,
.data-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.portal-table td,
.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.portal-table tbody tr:hover,
.data-table tbody tr:hover {
  background-color: var(--bg-surface-hover);
}

/* Badges & Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-gold {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
}

.pill-green {
  background: var(--success-bg);
  color: var(--success);
}

.pill-amber {
  background: var(--warning-bg);
  color: var(--warning);
}

.pill-red {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

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

/* Theme Switcher Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  user-select: none;
  outline: none;
}

.theme-toggle-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--gold-border);
  color: var(--gold-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn svg {
  width: 17px;
  height: 17px;
  color: var(--gold-primary);
  transition: transform var(--transition-fast);
}

.theme-toggle-btn:hover svg {
  transform: rotate(15deg);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-surface-hover);
  color: var(--gold-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold-border);
}

/* Flash Toasts */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--gold-primary);
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 320px;
  animation: slideIn 0.3s ease-out;
}

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

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

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .app-header {
    padding: 0 1rem;
  }
  .app-content {
    padding: 1rem;
  }
}
