/* CS Agent — Admin Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a2e;
    background: #f0f2f5;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid #2a2a4a;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.sidebar-footer {
    border-top: 1px solid #2a2a4a;
    padding: 8px 0;
}

.sidebar-nav li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 10px 16px;
    color: #b0b0c0;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
    background: #2a2a4a;
    color: #fff;
    text-decoration: none;
}

/* ── Main Content ──────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 24px 32px;
    overflow-x: auto;
}

/* ── Page Header ───────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a2e;
}

.page-header p {
    color: #666;
    margin-top: 4px;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* ── Stat Cards (Dashboard) ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 16px 20px;
}

.stat-card .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    margin-top: 4px;
}

/* ── Tables ────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.data-table tr:hover {
    background: #f8f9fb;
}

/* ── Status Badges ─────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-analyzing,
.badge-gathering,
.badge-resolving { background: #cce5ff; color: #004085; }
.badge-awaiting { background: #e2e3f1; color: #383d6e; }
.badge-draft { background: #d4edda; color: #155724; }
.badge-escalated { background: #f8d7da; color: #721c24; }
.badge-error { background: #f5c6cb; color: #721c24; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-rejected { background: #f8d7da; color: #721c24; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }

.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.4;
}

.form-hint code {
    font-size: 11px;
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
}

/* ── Timeline (Pipeline Detail) ────────────────────────── */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #2563eb;
    border: 2px solid #fff;
}

.timeline-item.completed::before { background: #16a34a; }
.timeline-item.error::before { background: #dc2626; }
.timeline-item.active::before { background: #f59e0b; }

.timeline-header {
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-body {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
}

.timeline-body pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    margin: 8px 0;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.timeline-meta {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* ── Collapsible sections ──────────────────────────────── */
.collapsible-toggle {
    cursor: pointer;
    user-select: none;
}

.collapsible-toggle::after {
    content: ' +';
    font-weight: bold;
}

.collapsible-toggle.open::after {
    content: ' -';
}

.collapsible-content {
    display: none;
}

.collapsible-content.open {
    display: block;
}

/* ── No-sidebar (login page) ──────────────────────────── */
.app-layout.no-sidebar .main-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .sidebar-header {
        padding: 12px 16px;
        border-bottom: none;
        border-right: 1px solid #2a2a4a;
        white-space: nowrap;
    }

    .sidebar-nav {
        display: flex;
        padding: 0;
    }

    .nav-link {
        white-space: nowrap;
        padding: 12px 14px;
    }

    .main-content {
        padding: 16px;
    }

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