@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #e2e8f0;
    --secondary-hover: #cbd5e1;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* --- LOGIN OVERLAY --- */
#loginOverlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    position: relative;
    width: 420px;
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    background: #ffffff;
    border: 1px solid var(--border-color);
}
.login-box h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 700;
    letter-spacing: -0.025em;
}
.login-box p {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 0.95rem;
}
.login-box input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
.login-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background: #ffffff;
}
.login-box button {
    width: 100%;
    padding: 0.875rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.login-box button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* --- ADMIN LAYOUT --- */
#adminLayout {
    display: none; /* Shown after login */
    width: 100%;
    height: 100vh;
}
#adminLayout.active {
    display: flex;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
}
.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-menu {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}
.sidebar-menu li {
    margin: 0.25rem 1rem;
}
.sidebar-menu .menu-heading {
    padding: 1.5rem 0.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}
.sidebar-menu a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}
.sidebar-menu a:hover {
    background: #f1f5f9;
    color: var(--text-color);
}
.sidebar-menu a.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-color);
}
.topbar {
    height: 72px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 40;
}
.content-area {
    padding: 2.5rem;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.page-title {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.page-title i {
    color: var(--primary);
}

/* Common UI Elements */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
}
.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn i {
    font-size: 1.1em;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn-secondary {
    background: #f1f5f9;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: #e2e8f0;
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: var(--danger-hover);
}
.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f8fafc;
}
tr:hover td {
    background: #f8fafc;
}
tr td:first-child, tr th:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}
tr td:last-child, tr th:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

/* Checkbox container */
.checkbox-list {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    max-height: 250px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: all 0.2s;
    background: #ffffff;
    border: 1px solid var(--border-color);
}
.checkbox-item:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
}

.view-section {
    display: none;
}
.view-section.active {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- STATUS BADGE --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.status-idle {
    background: #f1f5f9;
    color: #64748b;
}
.status-running {
    background: #ecfdf5;
    color: #059669;
}
.status-running i {
    animation: pulse 2s infinite;
}

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

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background: #ffffff;
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-xl);
}
.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover {
    color: var(--text-color);
    background: #f1f5f9;
}
.modal-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: 700;
}

/* SweetAlert */
div:where(.swal2-container) div:where(.swal2-popup) {
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
}

/* --- FOOTER --- */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: auto;
}
.app-footer span {
    font-weight: 600;
    color: var(--primary);
}
.login-footer {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.login-footer span {
    font-weight: 600;
    color: var(--text-color);
}

/* --- RESPONSIVE MOBILE --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 999;
}
.sidebar-overlay.open {
    display: block;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .hamburger {
        display: block;
    }
    .topbar {
        justify-content: space-between;
        padding: 0 1.5rem;
    }
    .content-area {
        padding: 1.5rem;
    }
}

/* --- TERMINAL --- */
#terminalBody {
    background: #0f172a !important;
    border-radius: 0;
    padding: 1.5rem !important;
    height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    color: #f8fafc !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
}

.activity-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    animation: fadeIn 0.3s ease;
}

.activity-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
    margin-top: 2px;
}

.activity-icon.info { color: #3b82f6; }
.activity-icon.success { color: #22c55e; }
.activity-icon.warn { color: #eab308; }
.activity-icon.error { color: #ef4444; }

.activity-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
}

.activity-time {
    font-size: 0.85rem;
    color: #64748b;
    white-space: nowrap;
}

.activity-message {
    color: #f8fafc;
    font-size: 0.9rem;
    line-height: 1.5;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fix SweetAlert z-index behind modals */
.swal2-container { z-index: 9999 !important; }
