/* Task Management App - Styles */
:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --success: #107c10;
  --warning: #ffb900;
  --danger: #d13438;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #6c757d;
  --gray-700: #495057;
  --gray-900: #212529;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 8px;
}

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

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

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

header {
  background: var(--primary);
  color: white;
  padding: 0 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info {
  text-align: right;
  font-size: 0.875rem;
}

.user-name {
  font-weight: 600;
}

.user-role {
  opacity: 0.8;
  font-size: 0.75rem;
  text-transform: capitalize;
}

main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 5px;
  background: white;
  padding: 10px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.nav-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  transition: all 0.2s;
}

.nav-tab:hover {
  background: var(--gray-100);
}

.nav-tab.active {
  background: var(--primary);
  color: white;
}

.nav-tab.hidden {
  display: none;
}

/* Filter Tabs (inside cards) */
.filter-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 5px;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.filter-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-700);
  transition: all 0.2s;
}

.filter-tab:hover {
  background: white;
}

.filter-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.filter-trigger-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 5px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

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

/* Filter Panel Overlay (popout) */
.filter-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 500;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  padding-top: 80px;
  padding-left: 20px;
}

.filter-panel-overlay.hidden {
  display: none;
}

.filter-panel-popout {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 320px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease-out;
}

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

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.filter-panel-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.filter-panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: 0;
}

.filter-panel-close:hover {
  color: var(--gray-700);
}

.filter-panel-body {
  overflow-y: auto;
  flex: 1;
}

/* Filter Sections */
.filter-section {
  border-bottom: 1px solid var(--gray-200);
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-section-header {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--gray-700);
  transition: background 0.15s;
}

.filter-section-header:hover {
  background: var(--gray-100);
}

.filter-section-header span:first-child {
  font-size: 1rem;
}

.filter-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.2s;
  color: var(--gray-500);
}

.filter-arrow.expanded {
  transform: rotate(90deg);
}

.filter-section-body {
  padding: 10px 20px 15px;
  background: var(--gray-100);
}

.filter-options-list {
  max-height: 180px;
  overflow-y: auto;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 0.85rem;
}

.filter-option:hover {
  color: var(--primary);
}

.filter-option input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Date range row */
.date-range-row {
  display: flex;
  gap: 10px;
}

.date-input-group {
  flex: 1;
}

.date-input-group label {
  display: block;
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.form-control-sm {
  padding: 6px 8px;
  font-size: 0.8rem;
}

/* Filter chips for active filters */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 20px;
  font-size: 0.75rem;
}

.filter-chip-remove {
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}

.filter-chip-remove:hover {
  opacity: 1;
}

/* Date preset buttons */
.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 15px;
}

.date-preset-btn {
  padding: 5px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--gray-700);
}

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

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

/* Importance badges */
.importance-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.importance-urgent {
  background: #fee2e2;
  color: #dc2626;
}

.importance-high {
  background: #fef3c7;
  color: #d97706;
}

.importance-medium {
  background: #dbeafe;
  color: #2563eb;
}

.importance-low {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* Revision count badge */
.revision-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

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

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

.btn-warning {
  background: var(--warning);
  color: var(--gray-900);
}

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

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

.btn-outline:hover {
  background: var(--gray-100);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

select.form-control {
  cursor: pointer;
}

/* Task List */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  transition: box-shadow 0.2s;
}

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

.task-item.overdue {
  border-left: 4px solid var(--danger);
}

.task-item.pending-review {
  border-left: 4px solid var(--warning);
}

.task-item.completed {
  border-left: 4px solid var(--success);
  opacity: 0.7;
}

.task-checkbox {
  margin-top: 3px;
}

.task-content {
  flex: 1;
}

.task-title {
  font-weight: 600;
  margin-bottom: 5px;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--gray-500);
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.task-actions {
  display: flex;
  gap: 8px;
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-not-started {
  background: var(--gray-200);
  color: var(--gray-700);
}

.badge-in-progress {
  background: #cce5ff;
  color: #004085;
}

.badge-pending-review {
  background: #fff3cd;
  color: #856404;
}

.badge-completed {
  background: #d4edda;
  color: #155724;
}

.badge-overdue {
  background: #f8d7da;
  color: #721c24;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-lg {
  max-width: 700px;
}

/* History/Audit Trail Table */
.history-table {
  width: 100%;
  font-size: 0.85rem;
}

.history-table th {
  font-size: 0.7rem;
}

.history-table td {
  vertical-align: top;
}

/* Status dropdown in tables */
.status-select {
  min-width: 130px;
  font-size: 0.8rem;
  padding: 4px 8px;
}

/* Clickable elements */
.clickable {
  cursor: pointer;
}

.clickable:hover {
  opacity: 0.8;
}

.revision-badge.clickable:hover {
  text-decoration: underline;
}

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

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

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  background: var(--gray-100);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--gray-500);
}

tr:hover {
  background: var(--gray-100);
}

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

.login-card {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.login-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.login-subtitle {
  color: var(--gray-500);
  margin-bottom: 30px;
}

.login-btn {
  width: 100%;
  padding: 15px;
  font-size: 1rem;
}

/* Pending Approval Page */
.pending-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}

.pending-card {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 500px;
  width: 90%;
}

.pending-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

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

.empty-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

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

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

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

/* Grid */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .header-content {
    flex-direction: column;
    height: auto;
    padding: 15px 0;
    gap: 10px;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
  }

  .nav-tabs {
    overflow-x: auto;
  }

  .task-item {
    flex-direction: column;
  }

  .task-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.section-header > .filter-toolbar {
  flex: 1;
}

@media (max-width: 768px) {
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
  .section-header .btn {
    width: 100%;
  }
  .filter-panel-overlay {
    padding: 10px;
  }
  .filter-panel-popout {
    width: 100%;
    max-width: none;
  }
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
