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

:root {
    /* OpenClaw-inspired colors (matching Hub.ai) */
    --bg-deep: #050810;
    --bg-surface: #0a0f1a;
    --bg-elevated: #111827;
    --bg-card: #0d1321;

    --coral-bright: #ff4d4d;
    --coral-mid: #e63946;
    --coral-dark: #991b1b;
    --coral-glow: rgba(255, 77, 77, 0.4);

    --cyan-bright: #00e5cc;
    --cyan-mid: #14b8a6;

    --text-primary: #f0f4ff;
    --text-secondary: #8892b0;
    --text-muted: #5a6480;

    --border-subtle: rgba(136, 146, 176, 0.15);
    --border-accent: rgba(255, 77, 77, 0.3);

    /* Agent-specific */
    --status-running: #00e5cc;
    --status-stopped: #f44336;
    --status-creating: #ff9800;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
.agents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border-subtle);
}

.agents-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-primary);
}

.agents-logo img {
    height: 36px;
    width: auto;
}

.agents-logo .logo-ai {
    color: var(--coral-bright);
}

.agents-nav {
    display: flex;
    gap: 24px;
    align-items: center;
}

.agents-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.agents-nav a:hover {
    color: var(--text-primary);
}

.user-info {
    color: var(--cyan-bright) !important;
}

/* Hero Section */
.agents-hero {
    text-align: center;
    padding: 60px 20px 40px;
    max-width: 800px;
    margin: 0 auto;
}

.agents-hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.agents-hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Template Gallery */
.template-gallery {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

@media (min-width: 768px) {
    .template-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1000px;
        margin: 0 auto;
    }
}

/* Template Card */
.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.template-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--coral-glow);
}

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

.template-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.template-deploy-btn {
    background: var(--coral-bright);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.template-deploy-btn:hover {
    background: var(--coral-mid);
    transform: scale(1.05);
}

.template-deploy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.template-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.template-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
    min-height: 60px;
}

.template-specs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.template-spec {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.template-loading, .agents-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Active Agents Section */
.active-agents {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.active-agents h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.agents-list {
    display: grid;
    gap: 16px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

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

.agent-info {
    flex: 1;
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.agent-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.agent-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    display: inline-block;
}

.agent-btn-primary {
    background: var(--coral-bright);
    color: white;
}

.agent-btn-primary:hover {
    background: var(--coral-mid);
}

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

.agent-btn-secondary:hover {
    border-color: var(--border-accent);
}

/* Status Badge */
.agent-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
}

.agent-status.running {
    background: rgba(0, 229, 204, 0.1);
    color: var(--cyan-bright);
}

.agent-status.stopped {
    background: rgba(244, 67, 54, 0.1);
    color: var(--status-stopped);
}

.agent-status.creating {
    background: rgba(255, 152, 0, 0.1);
    color: var(--status-creating);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

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

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 24px;
}

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

/* Modal Content Sections */
.modal-section {
    margin-bottom: 24px;
}

.modal-section h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Size Selection */
.size-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.size-select:hover {
    border-color: var(--border-accent);
}

.size-select:focus {
    outline: none;
    border-color: var(--coral-bright);
}

.modal-section ul {
    list-style: none;
}

.modal-section li {
    padding: 8px 0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section li::before {
    content: '•';
    color: var(--cyan-bright);
    font-weight: bold;
}

/* Progress Steps */
.progress-steps {
    list-style: none;
    margin: 24px 0;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    color: var(--text-muted);
}

.progress-step.completed {
    color: var(--cyan-bright);
}

.progress-step.active {
    color: var(--text-primary);
}

.progress-step.failed {
    color: var(--status-stopped);
}

.progress-step-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--coral-bright), var(--cyan-bright));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-percent {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Success Content */
.success-content {
    text-align: center;
}

.success-icon {
    font-size: 3rem;
    color: var(--cyan-bright);
    margin-bottom: 16px;
}

.success-url {
    background: var(--bg-elevated);
    padding: 12px;
    border-radius: 8px;
    margin: 16px 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    word-break: break-all;
}

.success-url a {
    color: var(--cyan-bright);
    text-decoration: none;
}

.success-url a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--coral-bright);
    color: white;
}

.btn-primary:hover {
    background: var(--coral-mid);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.btn-full {
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .agents-header {
        padding: 16px 20px;
    }

    .agents-nav {
        display: none; /* Simplified mobile header */
    }

    .agents-hero {
        padding: 40px 20px;
    }

    .agents-hero h1 {
        font-size: 2rem;
    }

    .template-grid {
        grid-template-columns: 1fr;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .agent-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .agent-actions {
        width: 100%;
        flex-direction: column;
    }

    .agent-btn {
        width: 100%;
        text-align: center;
    }

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

    .btn {
        width: 100%;
    }
}

/* Error State */
.error-message {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: var(--status-stopped);
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--bg-elevated);
    border-top: 3px solid var(--coral-bright);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
