/* =====================================================
   style.css — Light Mode · Tickets San Marino
   ===================================================== */

/* ---------- Variables ---------- */
:root {
  --bg-base:     #f0f2f7;
  --bg-card:     #ffffff;
  --bg-sidebar:  #1e2140;
  --bg-hover:    #f5f6fa;
  --bg-input:    #f8f9fc;
  --border:      #e2e6f0;

  --accent:      #5b52e8;
  --accent-dark: #4540c4;
  --accent-glow: rgba(91,82,232,.12);
  --teal:        #0db8b0;
  --danger:      #e84545;
  --warning:     #f59e0b;
  --success:     #10b981;

  --text-primary:   #1a1d2e;
  --text-secondary: #4b5068;
  --text-muted:     #9aa0b8;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 2px 12px rgba(30,33,64,.08);
  --transition: all .2s ease;
  --sidebar-w: 260px;
  --topbar-h:  64px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--teal); }

img { max-width: 100%; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo-icon { font-size: 28px; }

.logo-name {
  display: block;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
}
.logo-version {
  font-size: .72rem;
  color: rgba(255,255,255,.4);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 10px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: .9rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left: 3px solid #a89cff;
  padding-left: 9px;
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: var(--bg-sidebar);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: .72rem;
  color: rgba(255,255,255,.4);
}

.logout-btn {
  color: rgba(255,255,255,.35);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.logout-btn:hover { color: #ff8080; }

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: none;
}

.page-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- Content area ---------- */
.content-area {
  flex: 1;
  padding: 28px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

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

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

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.total::before    { background: var(--accent); }
.stat-card.open::before     { background: var(--teal); }
.stat-card.progress::before { background: var(--warning); }
.stat-card.resolved::before { background: var(--success); }

.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  font-size: 1.8rem;
  opacity: .15;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  line-height: 1;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

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

.btn-success {
  background: var(--success);
  color: #0d0d1a;
}

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

.btn-teal {
  background: var(--teal);
  color: #0d0d1a;
}

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

.btn-block { width: 100%; justify-content: center; }

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

.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: .9rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

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

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

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

thead th {
  background: #f8f9fc;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .88rem;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-hover); }

.td-main {
  color: var(--text-primary) !important;
  font-weight: 500;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.badge-open     { background: rgba(78,205,196,.15); color: var(--teal); }
.badge-progress { background: rgba(255,198,91,.15);  color: var(--warning); }
.badge-waiting  { background: rgba(108,99,255,.15);  color: var(--accent); }
.badge-resolved { background: rgba(86,215,152,.15);  color: var(--success); }
.badge-closed   { background: rgba(72,79,88,.25);    color: var(--text-muted); }

.priority-low      { background: rgba(86,215,152,.15); color: var(--success); }
.priority-medium   { background: rgba(78,205,196,.15); color: var(--teal); }
.priority-high     { background: rgba(255,198,91,.15); color: var(--warning); }
.priority-critical { background: rgba(255,107,107,.15); color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 20px;
  border-left: 4px solid;
}

.alert-success { background: rgba(86,215,152,.1);  border-color: var(--success); color: var(--success); }
.alert-error   { background: rgba(255,107,107,.1); border-color: var(--danger);  color: var(--danger); }
.alert-info    { background: rgba(108,99,255,.1);  border-color: var(--accent);  color: var(--accent); }
.alert-warning { background: rgba(255,198,91,.1);  border-color: var(--warning); color: var(--warning); }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}
.login-logo p { color: var(--text-muted); font-size: .85rem; margin-top: 4px; }

/* ---------- Ticket detail ---------- */
.ticket-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text-muted);
}

.meta-item strong { color: var(--text-secondary); }

.ticket-body {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text-secondary);
  font-size: .9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Comments ---------- */
.comments-list { margin-top: 8px; }

.comment {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}

.comment-avatar.admin-avatar {
  background: linear-gradient(135deg, var(--warning), var(--danger));
}

.comment-content { flex: 1; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 600;
  font-size: .88rem;
  color: var(--text-primary);
}

.comment-time {
  font-size: .78rem;
  color: var(--text-muted);
}

.comment-body {
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.internal-note { background: rgba(255,198,91,.05); border-radius: var(--radius-sm); padding: 12px; border-left: 3px solid var(--warning); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-secondary); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: .88rem; margin-bottom: 24px; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.filter-bar .form-control {
  width: auto;
  flex: 1;
  min-width: 140px;
  max-width: 200px;
  padding: 7px 12px;
  font-size: .85rem;
}

/* ---------- Ticket body (light) ---------- */
.ticket-body {
  background: #f8f9fc;
  border-color: var(--border);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #c8cce0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .content-area {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Utility ---------- */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .82rem; }
.mt-0        { margin-top: 0; }
.mb-0        { margin-bottom: 0; }
.d-flex      { display: flex; }
.align-items-center { align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.justify-between { justify-content: space-between; }
.w-100       { width: 100%; }
.text-right  { text-align: right; }

/* Ticket code chip */
.ticket-code {
  font-family: monospace;
  font-size: .82rem;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border-radius: 4px;
}
