/**
 * IFT Database - Modern Theme
 * Version: 2.0
 * 
 * A clean, professional dashboard theme for the IFT Tech Support Database.
 */

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

:root {
  /* Brand Colors */
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #ecfeff;
  --primary-50: #f0fdfa;
  
  /* Accent */
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  
  /* Neutrals */
  --white: #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* Semantic */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  
  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--gray-50);
  color: var(--gray-700);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   TOP NAVIGATION BAR
   ============================================ */
.topbar {
  background: var(--gray-900);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-logo {
  height: 40px;
  width: auto;
}

.topbar-title {
  color: var(--gray-400);
  font-size: 0.875rem;
  font-weight: 500;
  padding-left: var(--space-4);
  border-left: 1px solid var(--gray-700);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar-link {
  color: var(--gray-400);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.topbar-link:hover {
  color: var(--white);
  background: var(--gray-800);
}

.topbar-link.active {
  color: var(--white);
  background: var(--primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--gray-300);
  font-size: 0.875rem;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 600;
  font-size: 0.875rem;
}

.topbar-logout {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.topbar-logout:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   SUB NAVIGATION
   ============================================ */
.subnav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--gray-500);
}

.breadcrumb a {
  color: var(--gray-600);
  text-decoration: none;
}

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

.breadcrumb-sep {
  color: var(--gray-300);
}

.breadcrumb-current {
  color: var(--gray-800);
  font-weight: 500;
}

.subnav-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main {
  flex: 1;
  padding: var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
}

.page-subtitle {
  color: var(--gray-500);
  font-size: 0.9375rem;
}

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

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(8, 145, 178, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-success:hover {
  background: #059669;
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: 1rem;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.8125rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* Legacy button support */
.button,
input[type="submit"],
input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(8, 145, 178, 0.3);
}

.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
  transform: translateY(-1px);
}

/* ============================================
   FORMS
   ============================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-label .required,
.form-label .req {
  color: var(--error);
  margin-left: 2px;
}

.form-input,
.inputbox,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
select,
textarea {
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  transition: all 0.2s;
  width: 100%;
}

.form-input:hover,
.inputbox:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="tel"]:hover {
  border-color: var(--gray-400);
}

.form-input:focus,
.inputbox:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder,
.inputbox::placeholder {
  color: var(--gray-400);
}

textarea.form-input,
textarea.inputbox,
textarea {
  min-height: 120px;
  resize: vertical;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--gray-200);
}

/* Email Status Indicator */
#emailStatus {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

#emailStatus.valid {
  color: var(--success);
  background: var(--success-light);
}

#emailStatus.invalid {
  color: var(--error);
  background: var(--error-light);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
  overflow-x: auto;
}

.table,
table.box {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th,
table.box th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.table td,
table.box td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.table tbody tr,
table.box tbody tr {
  transition: background 0.15s;
}

.table tbody tr:hover,
table.box tbody tr:hover {
  background: var(--primary-50);
}

.table-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.table-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.table-id {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8125rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ============================================
   BADGES / STATUS PILLS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
}

.badge-success {
  background: var(--success-light);
  color: #065f46;
}

.badge-warning {
  background: var(--warning-light);
  color: #92400e;
}

.badge-error {
  background: var(--error-light);
  color: #991b1b;
}

.badge-info {
  background: var(--info-light);
  color: #1e40af;
}

.badge-neutral {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================
   ALERTS / MESSAGES
   ============================================ */
.alert,
.msgOk,
.msgError,
.msgAlert,
.msgInfo {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.alert-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-message {
  font-size: 0.875rem;
  opacity: 0.9;
}

.alert-success,
.msgOk {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.alert-success .alert-icon {
  background: var(--success);
  color: var(--white);
}

.alert-error,
.msgError {
  background: var(--error-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-error .alert-icon {
  background: var(--error);
  color: var(--white);
}

.alert-warning,
.msgAlert {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.alert-info,
.msgInfo {
  background: var(--info-light);
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* ============================================
   ACCORDION / EXPANDABLE SECTIONS
   ============================================ */
.accordion {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.accordion-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.accordion-item:hover {
  box-shadow: var(--shadow-md);
}

.accordion-item.active {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-800);
  text-align: left;
  transition: background 0.2s;
}

.accordion-header:hover {
  background: var(--gray-50);
}

.accordion-item.active .accordion-header {
  background: var(--primary);
  color: var(--white);
}

.accordion-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 1rem;
  transition: all 0.2s;
}

.accordion-item.active .accordion-icon {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  transform: rotate(45deg);
}

.accordion-content {
  display: none;
  padding: var(--space-5);
  background: var(--gray-25);
  border-top: 1px solid var(--gray-100);
}

.accordion-item.active .accordion-content {
  display: block;
}

/* ============================================
   DATA DISPLAY
   ============================================ */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.data-item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--gray-100);
}

.data-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: var(--space-1);
}

.data-value {
  font-size: 0.9375rem;
  color: var(--gray-800);
  font-weight: 500;
}

.data-value.highlight {
  color: var(--primary);
}

/* ============================================
   NOTES SECTION
   ============================================ */
.notes-form {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.note-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
}

.note-item:last-child {
  border-bottom: none;
}

.note-number {
  width: 28px;
  height: 28px;
  background: var(--gray-100);
  color: var(--gray-500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.note-content {
  flex: 1;
}

.note-meta {
  font-size: 0.8125rem;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.note-text {
  color: var(--gray-700);
  line-height: 1.6;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-4);
  flex-wrap: wrap;
}

.pagination a,
.pagination span,
.pagination-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.pagination a:hover,
.pagination-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  text-decoration: none;
}

.pagination .current,
.pagination-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pagination .disabled,
.pagination-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1a2332 100%);
  padding: var(--space-4);
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo img {
  height: 60px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.login-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: var(--space-6);
  text-align: center;
}

.login-header h1 {
  color: var(--white);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.login-body {
  padding: var(--space-8);
}

.login-footer {
  padding: var(--space-4);
  background: var(--gray-50);
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-100);
}

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .topbar {
    padding: var(--space-3) var(--space-4);
  }

  .topbar-nav {
    display: none;
  }

  .topbar-title {
    display: none;
  }

  .main {
    padding: var(--space-4);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .subnav {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .subnav-actions {
    width: 100%;
    margin-left: 0;
    margin-top: var(--space-2);
  }

  .subnav-actions .btn,
  .subnav-actions .button {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Mobile table to cards transformation */
  .table thead,
  table.box thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td,
  table.box,
  table.box tbody,
  table.box tr,
  table.box td {
    display: block;
    width: 100%;
  }

  .table tbody tr,
  table.box tbody tr {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
  }

  .table tbody tr:hover,
  table.box tbody tr:hover {
    background: var(--white);
  }

  .table td,
  table.box td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--gray-100);
  }

  .table td:last-child,
  table.box td:last-child {
    border-bottom: none;
    padding-top: var(--space-3);
    margin-top: var(--space-2);
  }

  .table td::before,
  table.box td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
  }

  .table td .btn,
  table.box td .btn,
  table.box td .button {
    width: 100%;
  }

  .data-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .login-container {
    margin: var(--space-4);
    max-width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-error { color: var(--error); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .topbar,
  .subnav,
  .btn,
  .button,
  .pagination {
    display: none !important;
  }

  body {
    background: white;
  }

  .main {
    padding: 0;
    max-width: 100%;
  }

  .card,
  .accordion-item {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
