/* SimpleSupport Admin Panel */

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --text: #1e293b;
  --text-muted: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
  --font: system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
}

.sidebar-nav {
  padding: 12px 0;
}

.sidebar-nav a {
  display: block;
  padding: 8px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--primary);
  background: #f1f5f9;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px 32px;
}

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

/* --- Stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: #f8fafc;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-resolved { background: #d1fae5; color: #047857; }
.badge-closed { background: #f1f5f9; color: #64748b; }
.badge-low { background: #f1f5f9; color: #64748b; }
.badge-medium { background: #fef3c7; color: #b45309; }
.badge-high { background: #fee2e2; color: #dc2626; }

/* --- Forms --- */
input, textarea, select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 12px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

button, .btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: all .15s;
  text-decoration: none;
}

button:hover, .btn:hover {
  border-color: var(--text-muted);
}

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

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

/* --- Login --- */
.login-container {
  max-width: 400px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.brand-dot {
  color: #6366F1;
  font-weight: 900;
  font-size: 1.2em;
  line-height: 1;
}
.brand-uk {
  color: #6366F1;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  font-size: 13px;
}

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

.login-links a:hover {
  text-decoration: underline;
}

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

.message-thread {
  margin: 24px 0;
}

.message {
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.message-customer {
  background: #f1f5f9;
  margin-right: 40px;
}

.message-agent {
  background: #eef2ff;
  margin-left: 40px;
}

.message-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* --- Filters bar --- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.filters-bar input,
.filters-bar select {
  width: auto;
  margin-bottom: 0;
}
.filter-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-dates label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter-dates input[type="date"] {
  width: auto;
  margin-bottom: 0;
  font-size: 13px;
  padding: 6px 10px;
}

/* --- Charts --- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* --- Info tooltip --- */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
}

.info-tip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.15s;
}

.info-tip:hover .info-tip-text,
.info-tip:focus .info-tip-text {
  visibility: visible;
  opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 16px;
  }

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