/* 
   Modern Design System - WorldBridge Online 
   Premium Dark/Light Theme with Glassmorphism 
*/

:root {
  /* Color Palette - Slate & Indigo Vibe */
  --bg-body-rgb: 15, 23, 42;
  --bg-body: #0f172a;
  /* Slate 900 */
  --bg-card: rgba(30, 41, 59, 0.7);
  /* Slate 800 with opacity */
  --bg-sidebar: #1e293b;
  /* Slate 800 */
  --text-primary: #f8fafc;
  /* Slate 50 */
  --text-secondary: #94a3b8;
  /* Slate 400 */
  --accent-primary: #6366f1;
  /* Indigo 500 */
  --accent-hover: #4f46e5;
  /* Indigo 600 */
  --danger: #ef4444;
  /* Red 500 */
  --success: #22c55e;
  /* Green 500 */
  --warning: #eab308;
  /* Yellow 500 */
  --border-color: rgba(148, 163, 184, 0.1);

  /* Spacing & Layout */
  --radius-lg: 16px;
  --radius-md: 8px;
  --radius-sm: 4px;
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-fast: 0.2s ease;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 25%),
    radial-gradient(circle at 90% 80%, rgba(34, 197, 94, 0.1) 0%, transparent 25%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
  transition: opacity var(--transition-fast);
}

a:hover {
  opacity: 0.8;
}

ul {
  list-style: none;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h2 {
  font-size: 2rem;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Layout Containers */
.app-container {
  display: flex;
  min-height: 100vh;
}

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%);
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 100%;
}

.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Components: Card (Glassmorphism) */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

.card-login {
  width: 100%;
  max-width: 400px;
}

/* Headers within Content */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Components: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
  color: white;
  box-shadow: 0 4px 10px -2px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px -3px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 10px -2px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

/* Components: Forms */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  transition: all var(--transition-fast);
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: rgba(15, 23, 42, 0.8);
}

/* Components: Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand img {
  height: 32px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar a {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  transform: translateX(4px);
}

.sidebar a svg {
  margin-right: 0.75rem;
  width: 20px;
  height: 20px;
}

/* Components: Topnav (Portal) */
.topnav-container {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topnav-links {
  display: flex;
  gap: 2rem;
}

.topnav a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
}

.topnav a:hover {
  color: var(--text-primary);
}

.topnav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-primary);
  transition: width 0.3s ease;
}

.topnav a:hover::after {
  width: 100%;
}

/* Components: Tables */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: var(--glass-border);
  box-shadow: var(--shadow-md);
}

table {
  width: 100%;
  border-collapse: separate;
  /* Changed for border-radius */
  border-spacing: 0;
  white-space: nowrap;
  background: rgba(30, 41, 59, 0.4);
}

th,
td {
  padding: 1.25rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th {
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

td {
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Specific Table Styles from Portal */
.disposition select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem;
  font-size: 0.85rem;
}

/* Utility Classes */
.no-copy {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Compact UI */
.compact-container {
  height: calc(100vh - 80px);
  /* Fill screen minus header */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  /* Balanced: Identity=Comm < History(slight boost) */
  gap: 1rem;
  flex: 1;
  overflow: hidden;
}

.compact-panel {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.table-compact th,
.table-compact td {
  padding: 0.5rem 0.65rem;
  /* Reduced horizontal padding for better fit */
  font-size: 0.9rem;
  white-space: nowrap;
  vertical-align: middle;
  /* Ensure alignment */
}

/* Fix width for stability */
.table-compact th {
  width: 35%;
  color: var(--text-secondary);
  font-weight: 500;
}

.table-compact td {
  width: 65%;
  color: var(--text-primary);
  font-weight: 600;
  /* Make values pop a bit more */
}

.table-compact {
  margin-bottom: 0;
  width: 100%;
  table-layout: fixed;
  /* Crucial for preventing jitter */
}

.active-nav {
  background: rgba(99, 102, 241, 0.2) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  color: var(--accent-primary) !important;
}

/* Utilities */
.text-center {
  text-align: center;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mt-8 {
  margin-top: 3rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-end {
  display: flex;
  justify-content: flex-end;
}

.gap-2 {
  gap: 0.5rem;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Custom Portal Elements */
.data-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Success Alert */
.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #86efac;
}