/* ==========================================================================
   1. DESIGN SYSTEM TOKENS (VARIABLES)
   ========================================================================== */
:root {
  /* Brand Palette */
  --primary: #2b6cb0;
  --primary-hover: #2c5282;
  --primary-light: #ebf8ff;
  --secondary: #4a5568;
  --secondary-hover: #2d3748;
  --accent: #805ad5;

  /* Feedback Colors */
  --success: #38a169;
  --success-bg: #c6f6d5;
  --success-text: #22543d;
  --danger: #e53e3e;
  --danger-bg: #fed7d7;
  --danger-text: #742a2a;
  --warning: #dd6b20;
  --warning-bg: #feebc8;
  --warning-text: #7b341e;

  /* Neutral Spectrum */
  --bg-main: #f7fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3182ce;
  --text-main: #2d3748;
  --text-muted: #718096;
  --text-inverse: #ffffff;

  /* Layout & Geometry */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. GLOBAL BASE & ACCESSIBILITY RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   3. NAVIGATION BAR
   ========================================================================== */
.navbar {
  background-color: #1a202c;
  color: var(--text-inverse);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.navbar .brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.navbar ul {
  display: flex;
  list-style: none;
  gap: 1rem;
  align-items: center;
}

.navbar a {
  color: #cbd5e0;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar a:hover,
.navbar a.active {
  color: var(--text-inverse);
  background-color: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   4. CONTAINERS & CARDS
   ========================================================================== */
.container {
  width: 100%;
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.admin-card {
  max-width: 520px;
  margin: 0 auto 2rem auto;
  background: var(--bg-card);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.edit-panel {
  background: var(--bg-card);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-focus);
  margin-top: 1.5rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   5. FORM ELEMENTS & INPUT GROUPS
   ========================================================================== */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-main);
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

/* ==========================================================================
   6. BUTTONS & CONTROLS
   ========================================================================== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  background-color: var(--primary);
  color: var(--text-inverse);
}

button:hover, .btn:hover {
  background-color: var(--primary-hover);
}

.admin-tab-btn {
  flex: 1;
  min-width: 120px;
  min-height: 48px;
  font-size: 0.95rem;
  font-weight: 700;
  background-color: var(--secondary);
  color: var(--text-inverse);
  border-radius: var(--radius-lg);
}

.admin-tab-btn.active {
  background-color: var(--primary);
}

.btn-action {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  background-color: var(--primary);
}

/* ==========================================================================
   7. DATA TABLES & WRAPPERS
   ========================================================================== */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: #edf2f7;
  color: #4a5568;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

tr:hover {
  background-color: rgba(237, 242, 247, 0.4);
}

/* ==========================================================================
   8. STATUS BADGES & NOTIFICATIONS
   ========================================================================== */
.badge-ok {
  background-color: var(--success-bg);
  color: var(--success-text);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
}

.badge-low {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
}

.status-msg {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
}

.status-msg.success {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #9ae6b4;
}

.status-msg.error {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #feb2b2;
}

/* ==========================================================================
   9. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 640px) {
  .navbar {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .navbar ul {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .admin-tab-btn {
    min-width: 100%;
  }
}