:root {
    /* Dark theme colors */
    --bg-primary: #0f0f12;
    --bg-secondary: #1a1a22;
    --bg-card: #22222d;
    --bg-input: #2a2a38;
    --bg-hover: #32324a;

    --text-primary: #f0f0f5;
    --text-secondary: #9090a0;
    --text-muted: #606070;

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);

    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #3b82f6;

    --border-color: #32324a;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --sidebar-width: 260px;
    --header-height: 64px;

    --transition: all 0.2s ease;
}

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

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

a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-primary);
}

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

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

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    list-style: none;
    padding: 16px;
    flex: 1;
}

.nav-menu li {
    margin-bottom: 8px;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-menu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-menu a.active {
    background: var(--accent-glow);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-primary);
}

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

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

.user-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

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

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

.logout-btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.main-full {
    padding: 32px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
    color: white;
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

.btn-success {
    background: var(--success);
    color: white;
}

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

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

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

.form-textarea {
    min-height: 150px;
    resize: vertical;
    font-family: 'Fira Code', monospace;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-draft {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.badge-ready {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.badge-scheduled {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
}

.badge-queued {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.badge-sending {
    background: rgba(234, 179, 8, 0.2);
    color: var(--warning);
}

.badge-completed {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-paused {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Flash messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flash {
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

.flash-success {
    background: var(--success);
    color: white;
}

.flash-error {
    background: var(--error);
    color: white;
}

.flash-warning {
    background: var(--warning);
    color: #1a1a22;
}

.flash-info {
    background: var(--info);
    color: white;
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Wizard steps */
.wizard-steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.wizard-step.active {
    background: var(--accent-glow);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-primary);
}

.wizard-step.completed {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.wizard-step.warning {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.wizard-step:hover:not(.active) {
    background: rgba(139, 92, 246, 0.15);
    transform: translateY(-1px);
}

.wizard-step-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Login page */
.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 32px;
    color: var(--text-primary);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

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

    .page-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
}

/* Tag legend */
.tag-legend {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    margin-bottom: 20px;
}

.tag-legend-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--accent-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.tag-item:hover {
    background: var(--accent-glow);
}

/* Preview frame */
.preview-frame {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    min-height: 400px;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Health Indicator */
.health-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.health-indicator:hover {
    background: var(--bg-hover);
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.health-dot.healthy {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.health-dot.degraded {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.health-dot.error {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.health-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Loading Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-input);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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