/* Force10 Base CSS - Shared styles across all pages
   Extracted from the inline <style> blocks in auth.html, admin.html, index.html */

/* ===== CSS RESET / NORMALIZE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent font size inflation on mobile */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scroll-behavior: smooth;
}

/* Remove default list styles */
ul, ol { list-style: none; }

/* Smooth images */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

/* Inherit fonts for form controls */
input, button, textarea, select {
  font: inherit;
}

/* Remove built-in form typography styles (normalize) */
button { cursor: pointer; }

/* Remove text decoration on anchors by default */
a {
  color: inherit;
  text-decoration: none;
}

/* Ensure table border-collapse */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ===== SKIP TO CONTENT LINK (Accessibility) ===== */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-lg);
  z-index: calc(var(--z-toast, 400) + 1);
  padding: var(--space-sm) var(--space-lg);
  background: var(--tp-primary);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: var(--space-lg);
  outline: var(--focus-ring);
}

/* ===== BASE BODY ===== */
body {
  font-family: var(--font-family);
  background: var(--g50);
  color: var(--g800);
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--g800);
  line-height: 1.3;
}

h1 { font-size: var(--font-size-xl); }
h2 { font-size: var(--font-size-lg); }
h3 { font-size: var(--font-size-md); }

/* Responsive typography */
@media (min-width: 768px) {
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
}

/* ===== FOCUS STYLES (Accessibility) ===== */
/* Visible focus ring for keyboard users only */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Remove focus ring for mouse/touch */
:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* Buttons and links need the offset ring for visibility */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--tp-primary);
  outline-offset: 2px;
  box-shadow: none;
}

/* Form inputs use the softer ring */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--tp-primary);
  box-shadow: var(--focus-ring);
}

/* ===== FORM ELEMENTS - Unified across all pages ===== */
input, select, textarea {
  font-family: inherit;
  font-size: var(--font-size-base);
  padding: 10px 14px;
  border: 1.5px solid var(--g200);
  border-radius: var(--radius-md);
  background: white;
  color: var(--g800);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--tp-primary);
  box-shadow: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--g500); /* 4.6:1 on white — passes AA */
}

textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--g600);
  margin-bottom: 5px;
}

.form-group { margin-bottom: var(--space-lg); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }

/* Validation state styles */
.input-error {
  border-color: var(--color-error) !important;
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.15) !important;
}

.input-success {
  border-color: var(--color-success) !important;
  box-shadow: 0 0 0 3px rgba(47, 133, 90, 0.15) !important;
}

.field-error-msg {
  font-size: var(--font-size-xs);
  color: var(--color-error);
  margin-top: var(--space-xs);
  display: none;
}

.input-error ~ .field-error-msg {
  display: block;
}

/* ===== BUTTONS - Unified ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  min-height: 44px; /* Touch target — WCAG 2.1 */
}

.btn-primary {
  background: var(--tp-primary);
  color: white; /* 5.6:1 contrast on --tp-primary */
}
.btn-primary:hover {
  background: var(--tp-primary-dark);
  box-shadow: 0 4px 12px rgba(43,98,171,0.3);
}

.btn-success { background: var(--color-success); color: white; }
.btn-success:hover { background: #256b48; }

.btn-danger { background: var(--color-error); color: white; }
.btn-danger:hover { background: #9b2c2c; }

.btn-outline {
  background: white;
  border: 1.5px solid var(--g200);
  color: var(--g600);
}
.btn-outline:hover {
  border-color: var(--tp-primary);
  color: var(--tp-primary);
  background: rgba(43,98,171,0.04);
}

.btn-gold { background: var(--tp-gold); color: white; }
.btn-gold:hover { background: #c49a3a; }

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  min-height: 36px;
}

.btn-header {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  height: 44px;
  min-width: 100px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.btn-header:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--g200);
  overflow: hidden;
}

.card-header {
  padding: 18px var(--space-xl);
  border-bottom: 1px solid var(--g100);
  font-weight: 600;
  font-size: var(--font-size-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: var(--space-xl); }
.card-footer { padding: var(--space-lg) var(--space-xl); border-top: 1px solid var(--g100); }

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, var(--tp-primary-dark) 0%, var(--tp-primary) 100%);
  padding: 14px var(--space-2xl);
  color: white;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-area img { height: 36px; }
.logo-area span { font-size: 18px; font-weight: 600; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== TABS - Unified ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--g200);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--g500); /* 4.6:1 on white — AA pass */
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  min-height: 44px; /* Touch target */
}

.tab-btn:hover { color: var(--g700); }
.tab-btn.active {
  color: var(--tp-primary);
  border-bottom-color: var(--tp-primary);
}

/* ===== MODALS - Unified ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn var(--transition-fast) ease;
}

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

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: visible;
  position: relative;
  animation: modalSlideUp var(--transition-normal) ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-body {
  max-height: calc(90vh - 140px);
  overflow-y: auto;
  padding: var(--space-xl);
}

.modal-header {
  padding: 20px 56px 20px var(--space-xl);
  border-bottom: 1px solid var(--g100);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--color-error);
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  z-index: 10;
  transition: background var(--transition-fast), color var(--transition-fast);
  min-height: 44px; /* Touch target */
  min-width: 44px;
}
.modal-close:hover { background: var(--color-error-light); color: #b91c1c; }

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--g100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== ALERTS & MESSAGES ===== */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-lg);
}

.alert-info {
  background: var(--color-info-light);
  border: 1px solid var(--color-info-border);
  color: var(--color-info); /* 9.2:1 on info bg — AA pass */
}

.alert-success {
  background: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: var(--color-success); /* 5.1:1 on success bg — AA pass */
}

.alert-warning {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning); /* 7.3:1 on warning bg — AA pass */
}

.alert-error {
  background: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  color: var(--color-error); /* 5.6:1 on error bg — AA pass */
}

.error-msg {
  background: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
  display: none;
}

.success-msg {
  background: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: var(--color-success);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
  display: none;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: var(--space-xl);
  background: var(--g800);
  color: white;
  padding: var(--space-md) var(--space-xl);
  padding-right: var(--space-3xl);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  z-index: var(--z-toast);
  animation: slideUp var(--transition-normal) ease;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 420px;
}
.toast-close {
  position: absolute;
  top: 50%;
  right: var(--space-sm);
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.7;
  border-radius: var(--radius-xs);
}
.toast-close:hover,
.toast-close:focus {
  opacity: 1;
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 1px;
}
.toast-error { background: var(--color-error, #dc2626); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SAVING INDICATOR ===== */
.saving-indicator {
  position: fixed;
  top: var(--space-md);
  right: var(--space-xl);
  background: var(--tp-primary);
  color: white;
  padding: 6px var(--space-lg);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  z-index: var(--z-toast);
  display: none;
}

/* ===== UTILITY CLASSES ===== */

/* Visually hidden but accessible to screen readers */
.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Text truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flex centering */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Text alignment */
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Spacing utilities */
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-lg); }
.mt-3 { margin-top: var(--space-xl); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-lg); }
.gap-2 { gap: var(--space-lg); }


/* Required field indicator */
.required {
  color: var(--color-error);
  font-weight: 600;
}

/* Inline field error */
.field-error {
  font-size: var(--font-size-xs);
  color: var(--color-error);
  margin-top: var(--space-xs);
  display: none;
}

/* Form group error state */
.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
  border-color: var(--color-error);
}
.form-group.has-error .field-error {
  display: block;
}

/* Button loading state */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
/* ===== SCROLLBAR STYLING ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--g300) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--g300);
  border-radius: var(--radius-full);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--g400);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .header { padding: var(--space-md) var(--space-lg); }
  .header-inner { flex-direction: column; gap: 10px; }
}

/* ===== REDUCED MOTION (Accessibility) ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .header,
  .sidebar,
  .tab-bar,
  .btn,
  .modal-overlay,
  .toast,
  .saving-indicator,
  .skip-to-content {
    display: none !important;
  }
  .content-area { margin: 0; padding: 0; }
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }
  a { text-decoration: underline; }
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
