/* ============================================================
   Shorebird Self-Hosted Dashboard — Complete Stylesheet
   ============================================================ */

:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #cffafe;
    --accent: #06b6d4;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

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

/* ---- Login Page ---- */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%; max-width: 420px;
}
.login-card h1 {
    font-size: 28px; font-weight: 700; margin-bottom: 4px;
    color: var(--text); text-align: center;
}
.login-card .logo-icon {
    font-size: 48px; text-align: center; margin-bottom: 8px;
}
.login-card .subtitle {
    color: var(--text-secondary); text-align: center;
    margin-bottom: 28px; font-size: 14px;
}
.login-error {
    background: var(--danger-light); color: var(--danger);
    padding: 10px 14px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 13px; display: none;
}

/* ---- Layout ---- */
.app-container { display: none; }
.app-container.active { display: block; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 240px; background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100; padding: 0;
}
.sidebar-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-header .logo {
    width: 32px; height: 32px; background: var(--primary);
    border-radius: 8px; display: flex; align-items: center;
    justify-content: center; color: #fff; font-weight: 700;
    font-size: 18px;
}
.sidebar-header h2 { font-size: 16px; font-weight: 600; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; border-radius: var(--radius);
    color: var(--text-secondary); text-decoration: none;
    font-size: 14px; font-weight: 500; transition: all .15s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover { background: #f1f5f9; color: var(--text); }
.sidebar-nav a.active {
    background: var(--primary-light); color: var(--primary-dark);
    font-weight: 600;
}
.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    font-size: 13px; color: var(--text-muted);
}

.main-content {
    margin-left: 240px; padding: 32px 40px; min-height: 100vh;
}

/* ---- Top Bar ---- */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px;
}
.top-bar h2 { font-size: 24px; font-weight: 700; }
.top-bar .user-info {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; color: var(--text-secondary);
}
.top-bar .btn-sm {
    padding: 6px 14px; font-size: 13px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all .15s;
}
.top-bar .btn-sm:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ---- Cards & Stats ---- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.stat-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-value {
    font-size: 32px; font-weight: 700; color: var(--text);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 13px; color: var(--text-muted); margin-top: 4px;
}
.stat-card.primary { border-left: 3px solid var(--primary); }
.stat-card.success { border-left: 3px solid var(--success); }
.stat-card.warning { border-left: 3px solid var(--warning); }

/* ---- Tables ---- */
.card {
    background: var(--surface); border-radius: var(--radius-lg);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}
.card-header {
    padding: 18px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 0; }

table {
    width: 100%; border-collapse: collapse;
}
thead th {
    text-align: left; padding: 12px 24px;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
tbody td {
    padding: 12px 24px; border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block; padding: 2px 10px; border-radius: 100px;
    font-size: 12px; font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

.code {
    font-family: var(--mono); font-size: 13px;
    background: #f1f5f9; padding: 2px 8px; border-radius: 4px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: .85; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #f8fafc; }
.btn-ghost {
    background: transparent; border-color: transparent;
    color: var(--text-secondary); padding: 6px 10px;
}
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; margin-bottom: 5px;
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.form-group input, .form-group select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; font-family: var(--font);
    transition: border-color .15s; outline: none;
    background: var(--surface);
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8,145,178,.1); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- Modals ---- */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,.5); z-index: 200;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 28px; width: 100%;
    max-width: 480px; max-height: 80vh; overflow-y: auto;
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---- Toast ---- */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
    animation: slideIn .25s ease-out;
    max-width: 380px;
}
.toast-success { background: #065f46; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ---- Empty State ---- */
.empty-state {
    text-align: center; padding: 60px 20px;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

/* ---- Section visibility ---- */
.page-section { display: none; }
.page-section.active { display: block; }

/* ---- Spinner ---- */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ---- Server info card ---- */
.info-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.info-item { }
.info-item .info-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.info-item .info-value { font-size: 14px; color: var(--text); margin-top: 2px; word-break: break-all; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 20px; }
}
@media (max-width: 600px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---- Tab bar for settings ---- */
.tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.tab-bar button {
    padding: 10px 20px; border: none; background: none;
    font-size: 14px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all .15s;
}
.tab-bar button.active {
    color: var(--primary); border-bottom-color: var(--primary); font-weight: 600;
}
.tab-bar button:hover { color: var(--text); }
