/* CSS Variables */
:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-urgent: #dc2626;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-sm: 4px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

/* Navigation */
.navbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.15s;
}

.nav-link:hover {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
}

.nav-separator {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 0.5rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-weight: 500;
  color: var(--color-text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
  text-decoration: none;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-large {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
}

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

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 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.5rem;
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-open { background: #dbeafe; color: #1d4ed8; }
.status-progress { background: #fef3c7; color: #b45309; }
.status-pending { background: #f3e8ff; color: #7c3aed; }
.status-resolved { background: #d1fae5; color: #047857; }
.status-closed { background: #f1f5f9; color: #475569; }

.priority-low { background: #f1f5f9; color: #475569; }
.priority-medium { background: #dbeafe; color: #1d4ed8; }
.priority-high { background: #fef3c7; color: #b45309; }
.priority-urgent { background: #fee2e2; color: #dc2626; }

.badge-internal { background: #fef3c7; color: #b45309; }
.badge-admin { background: #dbeafe; color: #1d4ed8; }

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

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}

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

.form-group input:disabled {
  background: var(--color-bg);
  color: var(--color-text-secondary);
}

.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.ticket-form,
.profile-form {
  max-width: 600px;
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.alert-success {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #6ee7b7;
}

/* Landing Page */
.landing {
  text-align: center;
  padding: 3rem 1rem;
}

.landing-hero {
  margin-bottom: 4rem;
}

.landing-hero h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 4rem;
}

.feature {
  text-align: center;
  padding: 1.5rem;
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
}

.feature h3 {
  margin-bottom: 0.5rem;
}

.feature p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.departments-preview h2 {
  margin-bottom: 1.5rem;
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 800px;
  margin: 0 auto;
}

.dept-card {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  text-align: left;
}

.dept-card h4 {
  margin-bottom: 0.25rem;
}

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

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

.dashboard-header h1 {
  font-size: 1.5rem;
}

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

.stat-card {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.queue-stat {
  border-left: 3px solid var(--color-primary);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.dashboard-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1rem;
}

.dashboard-section.full-width {
  grid-column: 1 / -1;
}

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

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.link-all {
  font-size: 0.75rem;
  color: var(--color-primary);
}

/* Ticket Lists */
.ticket-list.compact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ticket-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.15s;
}

.ticket-row:hover {
  background: var(--color-bg);
  text-decoration: none;
}

.ticket-ref {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  min-width: 70px;
}

.ticket-title {
  flex: 1;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-dept,
.ticket-from {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.ticket-time {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  min-width: 80px;
  text-align: right;
}

/* Ticket Table */
.ticket-table {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.table-header,
.table-row {
  display: grid;
  grid-template-columns: 90px 1fr 100px 90px 120px 110px;
  padding: 0.75rem 1rem;
  gap: 0.75rem;
  align-items: center;
}

.table-header {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.table-row {
  border-top: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.15s;
}

.table-row:hover {
  background: var(--color-bg);
}

.col-ref { font-family: monospace; font-size: 0.875rem; }
.col-title { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-status, .col-priority { font-size: 0.875rem; }
.col-from, .col-assigned, .col-dept { font-size: 0.875rem; color: var(--color-text-secondary); }
.col-updated { font-size: 0.75rem; color: var(--color-text-secondary); text-align: right; }

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

.empty-state.small {
  padding: 1.5rem 1rem;
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.empty-state p {
  margin-bottom: 1rem;
}

/* Ticket View */
.ticket-view {
  display: grid;
  gap: 1.5rem;
}

.ticket-header {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.ticket-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ticket-header h1 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.ticket-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.ticket-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
}

.ticket-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.ticket-description {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.ticket-description h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.description-text {
  white-space: pre-wrap;
  font-size: 0.875rem;
}

.comments-section {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.comments-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.comment {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
}

.comment-internal {
  background: #fef3c7;
  border: 1px dashed #f59e0b;
}

.comment-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.comment-time {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  margin-left: auto;
}

.comment-content {
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.no-comments {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

.comment-form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.comment-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.internal-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.ticket-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-section {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.sidebar-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
}

.inline-form {
  margin-bottom: 0.75rem;
}

.inline-form label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.inline-form select {
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.details-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.details-list dt {
  color: var(--color-text-secondary);
}

.details-list dd {
  text-align: right;
}

.activity-list {
  list-style: none;
  font-size: 0.75rem;
}

.activity-list li {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.activity-list li:last-child {
  border-bottom: none;
}

.activity-user {
  font-weight: 500;
}

.activity-action {
  color: var(--color-text-secondary);
}

.activity-value {
  font-weight: 500;
}

.activity-time {
  margin-left: auto;
  color: var(--color-text-secondary);
}

/* Profile Page */
.setup-banner {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  text-align: center;
}

.setup-banner h2 {
  margin-bottom: 0.5rem;
}

/* Admin Pages */
.admin-table {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

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

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

.admin-table th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.admin-table td {
  font-size: 0.875rem;
}

.inline-edit-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-edit-form input,
.inline-edit-form select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.add-section {
  margin-top: 1.5rem;
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.add-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.form-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

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

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding: 0.5rem 0;
  }

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

  .ticket-content {
    grid-template-columns: 1fr;
  }

  .ticket-sidebar {
    order: -1;
  }

  .table-header,
  .table-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .table-header {
    display: none;
  }
}
