/* Mailserver Admin UI - Utility CSS */
/* Minimal hand-written subset inspired by Tailwind conventions */

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

:root {
  --bg: #1e293b;
  --bg-card: #334155;
  --bg-input: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-hover: #475569;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --warning: #f59e0b;
  --border: #475569;
  --radius: 0.5rem;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

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

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--bg-sidebar); padding: 1rem 0; flex-shrink: 0; border-right: 1px solid var(--border); }
.sidebar-brand { padding: 0 1rem 1rem; font-size: 1.1rem; font-weight: 700; color: var(--primary); border-bottom: 1px solid var(--border); margin-bottom: 0.5rem; }
.sidebar-nav { list-style: none; }
.sidebar-nav a { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1rem; color: var(--text-muted); text-decoration: none; transition: all 0.15s; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--bg-hover); color: var(--text); }
.main { flex: 1; display: flex; flex-direction: column; overflow-x: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.5rem; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.content { padding: 1.5rem; flex: 1; }

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-mono { font-family: var(--mono); font-size: 0.85rem; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; border: 1px solid var(--border); }
.card + .card { margin-top: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--border); text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: 0.875rem; font-weight: 500; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.form-input { width: 100%; padding: 0.5rem 0.75rem; background: var(--bg-input); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.875rem; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,0.25); }
select.form-input { appearance: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.03); }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 1rem; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger { background: rgba(244,63,94,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }

/* Health grid */
.health-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.health-item { font-size: 0.875rem; white-space: nowrap; }

/* Alerts / Toasts */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.875rem; animation: slideIn 0.3s ease; }
.toast-success { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid var(--success); }
.toast-error { background: rgba(244,63,94,0.15); color: var(--danger); border: 1px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 480px; border: 1px solid var(--border); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.25rem; }

/* Pagination */
.pagination { display: flex; gap: 0.25rem; align-items: center; margin-top: 1rem; }
.pagination .btn { min-width: 2rem; justify-content: center; }
.pagination .active { background: var(--primary); color: white; }

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* htmx loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
