/* =====================================================
   TICKET SYSTEM V2 - MODERN DESIGN
   Color Scheme: Red/Black/White/Gray Professional Modern
   ===================================================== */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* CSS Variables - Light Theme */
:root {
  --primary-color: #C41E3A;
  --primary-hover: #A61830;
  --primary-active: #8B1428;

  --secondary-color: #1a1a1a;
  --secondary-light: #333333;

  --bg-primary: #ffffff;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #efefef;

  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;

  --border-color: #e0e0e0;
  --border-light: #f0f0f0;

  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.18);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Courier New", monospace;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* Dark Theme */
body.dark-mode {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2a2a2a;

  --text-primary: #f8f8f8;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;

  --border-color: #333333;
  --border-light: #2a2a2a;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
}

/* ==================== Base Styles ==================== */

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: 2rem; line-height: 1.2; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.25rem; line-height: 1.3; }
h4 { font-size: 1.1rem; line-height: 1.4; }
h5 { font-size: 1rem; line-height: 1.5; }
h6 { font-size: 0.9rem; line-height: 1.5; }

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ==================== Layout ==================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.main-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  padding: 2rem 0;
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

.dashboard-main,
.management-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ==================== Header ==================== */

.header,
.dashboard-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
}

.header h1,
.dashboard-header h1 {
  font-size: 1.75rem;
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subtitle {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 0.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* ==================== Form Elements ==================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

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

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

/* ==================== Buttons ==================== */

button {
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Primary Button */
.submit-btn,
.add-ticket-btn {
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.submit-btn:hover,
.add-ticket-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.submit-btn:active,
.add-ticket-btn:active {
  background-color: var(--primary-active);
  transform: translateY(0);
}

/* Secondary Button */
.reset-btn,
.back-btn,
.action-btn {
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.reset-btn:hover,
.back-btn:hover,
.action-btn:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Save Button */
.save-btn {
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
  margin-top: 1rem;
}

.save-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.dropdown-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.2rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
}

/* ==================== Cards & Sections ==================== */

.form-section,
.info-section,
.stat-card,
.filters-section,
.tickets-section,
.management-table,
.login-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  transition: all var(--transition-normal);
}

.form-section:hover,
.stat-card:hover,
.filters-section:hover,
.tickets-section:hover {
  box-shadow: var(--shadow-md);
}

.form-section h2,
.filters-section h2,
.tickets-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.ticket-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ==================== Info Card ==================== */

.info-card {
  border-left: 4px solid var(--primary-color);
  padding: 1.5rem;
  background: var(--bg-secondary);
}

.info-card h3 {
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.info-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==================== Messages ==================== */

.success-message {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success-color);
  border-left: 4px solid var(--success-color);
  color: var(--success-color);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
}

.success-message h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.error-message {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error-color);
  border-left: 4px solid var(--error-color);
  color: var(--error-color);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
}

.error-message h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

/* ==================== Footer ==================== */

.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 3rem;
}

/* ==================== Login Page ==================== */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  padding: 1rem;
}

.login-box {
  max-width: 400px;
  width: 100%;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
  color: var(--primary-color);
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ==================== User Dropdown ==================== */

.user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.username {
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
}

.user-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
  z-index: 2000;
  animation: slideDown var(--transition-normal);
}

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

.user-dropdown.open .dropdown-menu {
  display: block;
}

.user-dropdown .dropdown-menu a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
}

.user-dropdown .dropdown-menu a:last-child {
  border-bottom: none;
}

.user-dropdown .dropdown-menu a:hover {
  background-color: var(--bg-secondary);
  color: var(--primary-color);
}

/* ==================== Dashboard Statistics ==================== */

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

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

.stat-card {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--primary-color);
}

.stat-card.open::before {
  background-color: #ef4444;
}

.stat-card.in-progress::before {
  background-color: #f59e0b;
}

.stat-card.remediation::before {
  background-color: #8b5cf6;
}

.stat-card.closed::before {
  background-color: #10b981;
}

.stat-card h3 {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-card.open .stat-number {
  color: #ef4444;
}

.stat-card.in-progress .stat-number {
  color: #f59e0b;
}

.stat-card.remediation .stat-number {
  color: #8b5cf6;
}

.stat-card.closed .stat-number {
  color: #10b981;
}

/* ==================== Filters ==================== */

.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  flex: 1;
  min-width: 150px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.filters select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

/* ==================== Tables ==================== */

.tickets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.tickets-table,
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.tickets-table thead,
.users-table thead {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

.tickets-table th,
.users-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.tickets-table td,
.users-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

.tickets-table tbody tr,
.users-table tbody tr {
  transition: background-color var(--transition-fast);
}

.tickets-table tbody tr:hover,
.users-table tbody tr:hover {
  background-color: var(--bg-secondary);
}

.tickets-table tbody tr:last-child td,
.users-table tbody tr:last-child td {
  border-bottom: none;
}

.loading-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* ==================== Status Badges ==================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-open {
  background-color: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.status-in-progress {
  background-color: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
}

.status-remediation {
  background-color: rgba(139, 92, 246, 0.15);
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.3);
}

.status-closed {
  background-color: rgba(16, 185, 129, 0.15);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

/* ==================== Priority Colors ==================== */

.priority-low {
  color: var(--success-color);
  font-weight: 600;
}

.priority-normal {
  color: var(--info-color);
  font-weight: 600;
}

.priority-high {
  color: var(--warning-color);
  font-weight: 600;
}

.priority-critical {
  color: var(--error-color);
  font-weight: 700;
}

/* ==================== Pagination ==================== */

.pagination-section {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

.pagination {
  display: flex;
  gap: 0.5rem;
}

.pagination button {
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 2.25rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.pagination button:hover {
  background-color: var(--bg-secondary);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.pagination button.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

/* ==================== Modal ==================== */

.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  animation: fadeIn var(--transition-normal);
}

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

.modal-content {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  animation: slideUp var(--transition-normal);
}

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

.close-btn {
  position: absolute;
  right: 1.5rem;
  top: 1.5rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-content h2 {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  padding-right: 2rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ticket-detail-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ticket-detail-group label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ticket-detail-group p {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
  margin: 0;
}

.ticket-detail-group textarea,
.ticket-detail-group select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.ticket-detail-group textarea:focus,
.ticket-detail-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

/* ==================== Form Actions ==================== */

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

/* ==================== Management Page ==================== */

.management-container {
  min-height: 100vh;
  background: var(--bg-primary);
}

.management-actions {
  margin-bottom: 1.5rem;
}

.management-table {
  padding: 0;
}

/* ==================== Responsive Design ==================== */

@media (max-width: 768px) {
  .header h1,
  .dashboard-header h1 {
    font-size: 1.25rem;
  }

  .header-content,
  .dashboard-header .header-content {
    flex-direction: column;
    gap: 1rem;
    padding: 0;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .main-content {
    gap: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .filters {
    flex-direction: column;
  }

  .filters select {
    width: 100%;
  }

  .tickets-table,
  .users-table {
    font-size: 0.85rem;
  }

  .tickets-table th,
  .users-table th,
  .tickets-table td,
  .users-table td {
    padding: 0.75rem;
  }

  .tickets-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
  }

  .modal-content h2 {
    font-size: 1.25rem;
    padding-right: 1.5rem;
  }

  .form-section,
  .info-section,
  .stat-card,
  .filters-section,
  .tickets-section {
    padding: 1.5rem;
  }

  .ticket-form {
    gap: 1rem;
  }

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

@media (max-width: 480px) {
  .header h1,
  .dashboard-header h1 {
    font-size: 1.1rem;
  }

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

  .pagination {
    gap: 0.25rem;
  }

  .pagination button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    min-width: auto;
  }

  .submit-btn,
  .add-ticket-btn,
  .reset-btn,
  .back-btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
  }
}

/* ==================== Dark Mode Adjustments ==================== */

body.dark-mode .submit-btn:hover,
body.dark-mode .add-ticket-btn:hover {
  box-shadow: var(--shadow-lg);
}

body.dark-mode .status-badge {
  border-color: rgba(0, 0, 0, 0.3);
}

body.dark-mode .table-wrapper {
  border-color: var(--border-color);
}

/* ==================== Accessibility ==================== */

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
