/* Dashboard Styles */

.dashboard-body {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    color: var(--text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

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

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(168,85,247,0.15) 0%, rgba(6,182,212,0.15) 100%);
    color: var(--purple);
    border: 1px solid rgba(168,85,247,0.2);
}

.nav-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logout-btn {
    width: 100%;
    justify-content: center;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.logout-btn:hover {
    opacity: 1;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

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

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.user-plan {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
}

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

.main-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mobile-menu-toggle:hover {
    background: var(--bg-elevated);
}

.mobile-menu-toggle.active {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.stat-info .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.85rem;
}

/* Forms */
.form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238888a0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Phase Selector */
.phase-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.phase-option input {
    display: none;
}

.phase-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.phase-option input:checked + .phase-card {
    border-color: var(--purple);
    background: rgba(168,85,247,0.1);
}

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

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

.phase-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.phase-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Settings */
.settings-group {
    margin-bottom: 32px;
}

.settings-group h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.limits-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.limit-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: 8px;
}

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

.limit-value {
    font-weight: 600;
    color: var(--purple);
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: 8px;
    margin-bottom: 8px;
}

.api-key-display code {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--text);
}

.settings-hint {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Tasks List */
.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.task-item:hover {
    border-color: var(--border-hover);
}

.task-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.task-icon {
    font-size: 1.5rem;
}

.task-details h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.task-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.task-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.task-status.pending {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

.task-status.running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.task-status.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.task-status.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.task-status.enqueued {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

.task-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.task-status.inactive {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-dim);
}

/* Toast container */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
    }

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

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

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

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 16px;
    }

    .task-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
