:root {
    --primary: #6366f1;
    --bg: #040813;
    --card-bg: rgba(18, 25, 41, 0.95);
    --header-bg: rgba(10, 15, 28, 0.8);
    --text-main: #f8fafc;
    --text-soft: #94a3b8;
    --accent: #a855f7;
    --success: #10b981;
    --info: #3b82f6;
    --error: #ef4444;
    --warning: #f59e0b;
    --r2-base: "https://pub-dbc28bdbb7e442d789cab279a374a29e.r2.dev";
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background:
        radial-gradient(circle at 10% 10%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Modern Sidebar --- */
.sidebar {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
    position: fixed;
    height: 100vh;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar.collapsed .logo { display: none; }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-soft);
    padding: 0.8rem 1rem;
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-item i { width: 20px; font-size: 1.1rem; }
.sidebar.collapsed .nav-item span { display: none; }

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

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Content Area Adjustment */
.main-content {
    flex: 1;
    margin-left: 260px; /* Offset for sidebar */
    padding: 2rem;
    transition: all 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: 80px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -1px;
}

.logo span {
    color: var(--primary);
}

main {
    width: 100%; /* Giãn 100% màn hình */
    padding: 1.5rem;
    padding-bottom: 5rem;
}

/* Health Bar */
.health-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
}

.stat-box .count {
    font-size: 1.5rem;
    font-weight: 600;
}

.stat-box .label {
    font-size: 0.6rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Controls */
.controls-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--card-bg);
    padding: 0.8rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.search-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 0.8rem;
    font-size: 0.8rem;
    outline: none;
}

.filter-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-soft);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.6rem;
    cursor: pointer;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
}

/* Job Card 4.0 */
.card {
    background: var(--card-bg);
    border-radius: 1.5rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.4);
    transition: all 0.25s ease;
}

.card.is-deleting {
    opacity: 0;
    transform: scale(0.9);
}

.media-area {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.media-area video,
.media-area img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-content {
    padding: 1.5rem;
}

.job-id-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.job-id {
    font-size: 0.65rem;
    font-family: monospace;
    color: var(--text-soft);
    word-break: break-all;
    cursor: pointer;
    user-select: all;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}
.job-id:hover { color: var(--accent); }

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2px;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.time-pill {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
}

.prog-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.prog-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: all 0.5s ease;
}

.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
}

.badge-stt,
.badge-rendering {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-success,
.badge-completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-error,
.badge-failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.badge-cancelled {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.status-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
}

.btn {
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.6rem;
    border-radius: 0.6rem;
    text-align: center;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-side {
    background: rgba(255, 255, 255, 0.05);
}

.btn:hover {
    filter: brightness(1.2);
}

/* Admin Controls */
.admin-controls {
    display: flex;
    gap: 8px;
}

.btn-admin {
    flex: 1;
    padding: 0.4rem;
    font-size: 0.65rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-soft);
    font-weight: 700;
    cursor: pointer;
}

.btn-retry:hover {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-stop:hover {
    background: var(--warning);
    color: #000;
    border-color: var(--warning);
}

.btn-delete:hover {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.timeline-btn {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 0.65rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 10px;
}

.collapsible {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.6rem;
}

.collapsible.open {
    max-height: 250px;
    padding: 0.8rem;
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.pulse {
    animation: pulse 2s infinite;
}
/* --- Modals 2.0 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 500px;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.test-panel {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.test-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 0.9rem;
}

.test-form-span-full {
    grid-column: 1 / -1;
}

.test-form-wide {
    grid-column: span 2;
}

.test-action-row {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.test-curl-preview {
    margin: 0;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 0.9rem;
    font-size: 0.67rem;
    line-height: 1.45;
    color: var(--text-main);
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 170px;
}

.saved-tests-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.7rem;
}

.saved-test-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.85rem;
    padding: 0.8rem;
}

.saved-test-item.active {
    border-color: rgba(99, 102, 241, 0.9);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4) inset;
}

.saved-test-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.saved-test-meta {
    font-size: 0.67rem;
    color: var(--text-soft);
    margin-bottom: 0.7rem;
}

.saved-test-actions {
    display: flex;
    gap: 0.45rem;
}

@media (max-width: 1280px) {
    .test-form-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .test-form-wide {
        grid-column: 1 / -1;
    }
}

@media (max-width: 720px) {
    .test-form-grid {
        grid-template-columns: 1fr;
    }

    .test-form-wide,
    .test-form-span-full {
        grid-column: 1 / -1;
    }
}
