/* Linear Design System CSS Variables */
:root {
    --bg-canvas: #010102;
    --bg-card: #090a0c;
    --bg-card-hover: #0e1014;
    --bg-input: #0b0c0e;
    --border-color: #1c1e22;
    --border-hover: #2d3139;
    
    --text-primary: #f7f8f8;
    --text-secondary: #8a8f98;
    --text-muted: #626875;
    
    --accent: #5e6ad2;
    --accent-hover: #707ce3;
    --accent-glow: rgba(94, 106, 210, 0.15);
    
    --success: #4ade80;
    --success-glow: rgba(74, 222, 128, 0.2);
    --error: #f87171;
    --error-glow: rgba(248, 113, 113, 0.2);
    --warning: #fbbf24;
    --inactive: #4b5563;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

body {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Screens toggling */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
    flex-direction: column;
}

/* Login Screen Layout */
#login-screen {
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #10111a 0%, var(--bg-canvas) 70%);
}

.login-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 80px rgba(94, 106, 210, 0.05);
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.logo h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 30px;
}

/* Forms and Inputs */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    transition: var(--transition-fast);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 15px rgba(94, 106, 210, 0.4);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
}

.btn-danger {
    background-color: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.2);
    color: var(--error);
}

.btn-danger:hover {
    background-color: var(--error);
    color: #000;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.btn-text:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Spinners for button loading */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.btn.loading .spinner {
    display: block;
}
.btn.loading span {
    display: none;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    background-color: rgba(1, 1, 2, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-name {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.3px;
}

.badge {
    background-color: rgba(94, 106, 210, 0.1);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(94, 106, 210, 0.2);
}

.system-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-right: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Dashboard Layout */
.dashboard-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}

.content-header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

/* Project Card */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.project-title-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.project-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Glowing container status indicators */
.status-running {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}
.status-stopped {
    background-color: var(--inactive);
}
.status-partial {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}
.status-error {
    background-color: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.project-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    flex: 1;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.meta-label {
    color: var(--text-secondary);
}

.meta-value {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta-value.mono {
    font-family: var(--font-mono);
}

.meta-value a {
    color: var(--accent);
    text-decoration: none;
}
.meta-value a:hover {
    text-decoration: underline;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: auto;
}

.card-actions button {
    flex: 1;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.3s ease-out;
}

.modal-lg {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-header .close-modal-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .close-modal-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-body.bg-dark {
    background-color: #030406;
}

#logs-modal .modal-body {
    padding: 0;
    overflow: hidden;
}

#logs-modal .logs-console {
    max-height: 60vh;
    height: 500px;
    margin: 0;
    border-radius: 0;
    padding: 20px;
    overflow: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* Env variables rows */
.env-section {
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

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

.env-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.env-row input {
    flex: 1;
}

.remove-env-btn {
    background: none;
    border: none;
    color: var(--error);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 6px;
}

/* Console logs */
.logs-console {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #d1d5db;
    background-color: #030406;
    padding: 16px;
    border-radius: 6px;
    overflow-y: auto;
    max-height: 450px;
    white-space: pre-wrap;
}

/* Toggle switch styling */
.toggle-group {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    text-transform: none;
    font-size: 13px;
    font-weight: 400;
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* Settings API Guidelines layout */
.api-integration-guide {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.token-container {
    background-color: rgba(255,255,255,0.02);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    padding: 16px;
}

.token-copy-box {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.token-copy-box input {
    font-family: var(--font-mono);
    font-size: 13px;
}

.code-snippet-box {
    margin-top: 10px;
}

.code-snippet-box pre {
    background-color: #030406;
    padding: 12px 16px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.tok-placeholder {
    color: var(--accent);
    font-weight: bold;
}

.divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* Message states */
.error-msg {
    color: var(--error);
    font-size: 12px;
    margin-top: 10px;
    text-align: center;
}

.success-msg {
    color: var(--success);
    font-size: 12px;
    margin-top: 10px;
    text-align: center;
}

/* Toast Notification styling */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background-color: #0e1014;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: 6px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    font-size: 13px;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-error {
    border-left-color: var(--error);
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding-left: 10px;
}

/* Skeleton Loading card style */
.card.skeleton {
    height: 240px;
    background: linear-gradient(90deg, #090a0c 25%, #15181e 50%, #090a0c 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

/* Keyframe Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive / Mobile Design Queries */
@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
    }
    
    .nav-left .badge {
        display: none; /* Hide badge to save mobile space */
    }
    
    .system-stats {
        gap: 8px;
        margin-right: 10px;
    }
    
    .stat-item {
        padding: 2px 6px;
        gap: 4px;
    }
    
    .stat-label {
        font-size: 9px;
    }
    
    .stat-value {
        font-size: 11px;
    }
    
    #logout-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 600px) {
    .dashboard-content {
        padding: 24px 16px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .header-actions {
        width: 100%;
        gap: 8px;
    }
    
    .header-actions .btn {
        flex: 1;
        width: 100%;
        padding: 10px;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .card-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .card-actions button {
        flex: 1 1 45%;
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .card-actions .btn-danger {
        flex: 1 1 100%; /* Delete button spans full width at the bottom */
    }
    
    .modal {
        max-height: 95vh;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 16px;
    }
    
    .env-row {
        flex-direction: column;
        gap: 6px;
        background-color: rgba(255,255,255,0.02);
        padding: 10px;
        border-radius: 6px;
        border: 1px solid var(--border-color);
        position: relative;
    }
    
    .remove-env-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 24px;
        padding: 0;
    }
    
    .env-row input {
        width: 100%;
    }
    
    .env-row input.env-key {
        padding-right: 30px; /* Leave space for remove button */
    }
}
