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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #222;
    --text-primary: #f5f5f5;
    --text-secondary: #888;
    --text-muted: #555;
    --accent: #ff4d4d;
    --accent-hover: #ff6666;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #333;
    --border-hover: #444;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a0a0a 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    color: var(--accent);
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.login-form .input-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.1);
}

.login-form input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-login:hover {
    background: var(--accent-hover);
}

.btn-login:active {
    transform: scale(0.98);
}

/* Main Dashboard */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-small {
    color: var(--accent);
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-title .subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-refresh,
.btn-logout {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-refresh:hover,
.btn-logout:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-refresh.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Main Content */
.main {
    flex: 1;
}

/* Kill All Section */
.kill-all-section {
    text-align: center;
    margin-bottom: 3rem;
}

.btn-kill-all {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1.25rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.3);
}

.btn-kill-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(220, 38, 38, 0.4);
}

.btn-kill-all:active {
    transform: translateY(0);
}

.kill-all-hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Workflows Section */
.workflows-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.workflows-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Workflow Card */
.workflow-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.workflow-card:hover {
    border-color: var(--border-hover);
}

.workflow-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.workflow-card.active {
    border-left: 3px solid var(--success);
}

.workflow-card.inactive {
    border-left: 3px solid var(--text-muted);
}

.workflow-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workflow-status {
    display: flex;
    align-items: center;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s;
}

.status-indicator.on {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-indicator.off {
    background: var(--text-muted);
}

.workflow-details {
    display: flex;
    flex-direction: column;
}

.workflow-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.workflow-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
    background-color: var(--success);
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
    padding: 1rem;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-icon {
    margin-bottom: 1.5rem;
}

.modal-icon.warning {
    color: var(--warning);
}

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.btn-cancel,
.btn-confirm-danger {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-cancel:hover {
    border-color: var(--border-hover);
}

.btn-confirm-danger {
    background: var(--error);
    border: none;
    color: white;
}

.btn-confirm-danger:hover {
    background: #dc2626;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1100;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 250px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--error);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-info {
    border-left: 3px solid var(--accent);
}

.toast button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
}

.toast button:hover {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 640px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .last-updated {
        display: none;
    }

    .btn-kill-all {
        width: 100%;
        justify-content: center;
    }

    .workflow-card {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .workflow-info {
        flex-direction: column;
    }

    .modal-actions {
        flex-direction: column;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast {
        min-width: auto;
    }
}
