/* TF SAFE CMMS - Stylesheet */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

/* Navigation */
.navbar {
  background: var(--gray-900);
  color: white;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 70px;
  gap: 1rem;
}

.nav-logos {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-right: 1rem;
  border-right: 1px solid var(--gray-700);
}

.logo-company {
  height: 32px;
  width: auto;
}

.logo-tfs {
  height: 50px;
  width: auto;
}

.nav-brand a {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  list-style: none;
  margin-left: auto;
  gap: 0.5rem;
}

.nav-links a {
  color: var(--gray-300);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.nav-links a:hover {
  background: var(--gray-700);
  color: white;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  background: #dc3545;
  border-color: #dc3545;
  color: white;
}

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

.btn-success {
  background: #10b981;
  border-color: #10b981;
  color: white;
}

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

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  min-width: 60px;
  text-align: center;
  display: inline-block;
}

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--gray-700);
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}

.form-group.required label::after {
  content: ' *';
  color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-section {
  margin-bottom: 2rem;
}

.form-section h2 {
  font-size: 1rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.form-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 2rem;
}

.inline-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.inline-form .form-group {
  margin-bottom: 0;
}

/* Filters */
.filters {
  margin-bottom: 1.5rem;
}

.filter-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
}

.filter-form input[type="date"] {
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
}

.btn-secondary {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

/* Report Form */
.report-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-form .form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.report-meta p {
  margin: 0.25rem 0;
}

.report-table {
  width: 100%;
}

@media print {
  .navbar, .footer, .no-print {
    display: none !important;
  }
  .container {
    max-width: 100%;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

.filter-form select {
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  min-width: 200px;
}

/* Tables */
.data-table {
  width: 100%;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-collapse: collapse;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table.compact th,
.data-table.compact td {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.data-table a:not(.btn) {
  color: var(--primary);
  text-decoration: none;
}

.data-table a:not(.btn):hover {
  text-decoration: underline;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-rac1, .badge-RAC1 {
  background: #fef2f2;
  color: var(--danger);
}

.badge-rac2, .badge-RAC2 {
  background: #fffbeb;
  color: var(--warning);
}

.badge-rac3, .badge-RAC3 {
  background: #f0fdf4;
  color: var(--success);
}

.badge-warning {
  background: #fffbeb;
  color: var(--warning);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--gray-100);
  color: var(--gray-700);
}

/* Progress Bar */
.progress-bar {
  width: 60px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

/* Priority rows */
.priority-rac1 {
  border-left: 3px solid var(--danger);
}

.priority-rac2 {
  border-left: 3px solid var(--warning);
}

.priority-rac3 {
  border-left: 3px solid var(--success);
}

/* Detail Grid */
.wo-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
}

.wo-detail-grid .full-width {
  grid-column: 1 / -1;
}

.detail-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
}

.detail-list dt {
  font-weight: 500;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.detail-list dd {
  color: var(--gray-900);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.alert-warning h3 {
  color: var(--warning);
  margin-bottom: 0.5rem;
}

.alert-row {
  background: #fffbeb !important;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
}

.empty-message {
  color: var(--gray-500);
  font-style: italic;
}

/* Report Styles */
.report-header {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.report-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.report-section h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--gray-700);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--gray-50);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
}

.summary-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

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

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* Page Actions */
.page-actions {
  margin-top: 1.5rem;
}

/* Print Styles */
@media print {
  .navbar, .footer, .no-print {
    display: none !important;
  }
  
  .container {
    max-width: 100%;
  }
  
  .report-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--gray-200);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .filter-form {
    flex-direction: column;
    align-items: stretch;
  }
  
  .inline-form {
    flex-direction: column;
  }
  
  .wo-detail-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table {
    font-size: 0.875rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }
}

/* Activity Section */
.activity-section {
  grid-column: 1 / -1;
}

.activity-form {
  background: var(--gray-100);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.activity-form .form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.activity-form .form-group {
  flex: 1;
  min-width: 150px;
}

.activity-table {
  margin-top: 1rem;
}

.help-text {
  color: var(--gray-600);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Search input in filter form */
.filter-form input[type="text"] {
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
}

/* Danger button for delete actions */
.btn-danger {
  background: #dc3545;
  color: white;
  border: none;
}

.btn-danger:hover {
  background: #c82333;
}

/* RAC Score badges */
.rac-1 {
  background: #dc3545;
  color: white;
}

.rac-2 {
  background: #fd7e14;
  color: white;
}

.rac-3 {
  background: #ffc107;
  color: #333;
}

.rac-4 {
  background: #28a745;
  color: white;
}

/* Alert styles */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-danger {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.alert-success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* Required field indicator */
.form-group.required label::after {
  content: " *";
  color: #dc3545;
}

/* Deficiency thumbnails */
.deficiency-thumbnail {
  max-width: 100px;
  max-height: 75px;
  margin-top: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--gray-300);
  cursor: pointer;
}

.deficiency-thumbnail:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* File input styling */
input[type="file"] {
  padding: 0.5rem;
  border: 1px dashed var(--gray-300);
  border-radius: 6px;
  width: 100%;
  background: var(--gray-100);
}

/* Login page styles */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #1a365d 100%);
}

.login-container {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 80px;
  height: auto;
  margin-bottom: 1rem;
}

.login-header h1 {
  margin: 0;
  color: var(--primary);
}

.login-header p {
  color: var(--gray-500);
  margin-top: 0.5rem;
}

.login-form .form-group {
  margin-bottom: 1rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
}

/* User info in navbar */
.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
}

.nav-user .user-name {
  font-weight: 500;
}

.nav-user .user-role {
  font-size: 0.8rem;
  opacity: 0.8;
}

.nav-user .btn-logout {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-user .btn-logout:hover {
  background: rgba(255,255,255,0.3);
}

/* Notification badge */
.notification-badge {
  background: #dc3545;
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  margin-left: 0.25rem;
}

/* Dashboard styles */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
}

.stat-card h3 {
  margin: 0;
  color: var(--gray-500);
  font-size: 0.9rem;
  text-transform: uppercase;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--primary);
  margin: 0.5rem 0 0;
}

.quick-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.alert-card {
  border-left: 4px solid #dc3545;
}

.badge-danger {
  background: #dc3545;
}

/* Admin panel styles */
.user-table .role-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.role-badge.admin { background: #6f42c1; color: white; }
.role-badge.qc { background: #17a2b8; color: white; }
.role-badge.inspector { background: #28a745; color: white; }

.status-active { color: #28a745; }
.status-inactive { color: #dc3545; }

/* Building image styles */
.building-image-container {
  max-width: 400px;
}

.building-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--gray-300);
}

.text-muted {
  color: var(--gray-500);
  font-style: italic;
}

/* Alert styles */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-danger {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.rejection-count {
  font-weight: normal;
  color: #856404;
  background: #fff3cd;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  font-size: 0.85rem;
}

.rejection-badge {
  display: inline-block;
  background: #dc3545;
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Filter Bar */
.filter-bar {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: 8px;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.filter-form select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 200px;
  cursor: pointer;
}

/* Notifications */
.notification-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notification-item {
  padding: 1rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
}

.notification-item.unread {
  background: #fff3cd;
  border-color: #ffc107;
}

.notification-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--gray-900);
}

.notification-message {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.notification-actions {
  display: flex;
  gap: 0.5rem;
}

/* QC Assignment */
.assign-form {
  display: inline;
}

.assign-form select {
  padding: 0.3rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
  min-width: 150px;
}

.nav-admin a {
  color: #ffc107 !important;
  font-weight: 500;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
}

.modal-content h3 {
  margin-bottom: 1rem;
}

/* Row highlighting for R&R */
.row-warning {
  background-color: #fff3cd !important;
}

.row-danger {
  background-color: #f8d7da !important;
}

/* Alert messages */
.alert {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
}

.alert-danger {
  background: #f8d7da;
  border: 1px solid #dc3545;
  color: #721c24;
}

.alert-success {
  background: #d4edda;
  border: 1px solid #28a745;
  color: #155724;
}

/* R&R Calendar Styles */
.rr-legend {
  padding: 0.5rem 1rem;
  background: var(--gray-50);
  border-radius: 4px;
}

.legend-box {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

.legend-box.master {
  background: #2563eb;
}

.legend-box.journeyman {
  background: #16a34a;
}

.legend-box.pending {
  background: #ffc107;
}

/* R&R Table Row Colors */
.rr-master {
  background-color: rgba(37, 99, 235, 0.1) !important;
  border-left: 4px solid #2563eb;
}

.rr-journeyman {
  background-color: rgba(22, 163, 74, 0.1) !important;
  border-left: 4px solid #16a34a;
}

.rr-pending {
  background-color: rgba(255, 193, 7, 0.2) !important;
  border-left: 4px solid #ffc107;
}

.gantt-table {
  width: 100%;
  border-collapse: collapse;
}

.gantt-table th,
.gantt-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.gantt-table th {
  background: var(--gray-100);
  font-weight: 600;
  font-size: 0.85rem;
}

.status-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Capacity Grid */
.capacity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 4px;
}

.capacity-day {
  padding: 4px;
  text-align: center;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: default;
}

.capacity-day .cap-date {
  display: block;
  font-weight: 600;
}

.capacity-day .cap-count {
  display: block;
  font-size: 0.9rem;
  font-weight: bold;
}

.cap-empty {
  background: var(--gray-100);
  color: var(--gray-500);
}

.cap-ok {
  background: #d4edda;
  color: #155724;
}

.cap-warn {
  background: #fff3cd;
  color: #856404;
}

.cap-full {
  background: #f8d7da;
  color: #721c24;
}

/* Annual Gantt Chart */
.gantt-annual-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.gantt-annual-table th,
.gantt-annual-table td {
  border: 1px solid var(--gray-300);
  padding: 0.4rem;
  text-align: center;
}

.gantt-name-header,
.gantt-name-cell {
  text-align: left;
  min-width: 150px;
  white-space: nowrap;
}

.gantt-type-header,
.gantt-type-cell {
  min-width: 80px;
}

.gantt-month-header {
  min-width: 60px;
  background: var(--gray-100);
  font-weight: 600;
}

.gantt-month-cell {
  min-width: 60px;
  height: 30px;
  position: relative;
}

.gantt-has-rr {
  padding: 0;
}

.gantt-bar {
  height: 100%;
  min-height: 24px;
  border-radius: 3px;
}

.gantt-bar-master {
  background: #2563eb;
}

.gantt-bar-journeyman {
  background: #16a34a;
}
