/* === CSS Custom Properties === */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;

    /* Stage colors */
    --accent-green: #22c55e;
    --accent-green-bg: #f0fdf4;
    --accent-amber: #f59e0b;
    --accent-amber-bg: #fffbeb;
    --accent-purple: #a855f7;
    --accent-purple-bg: #faf5ff;
    --accent-blue: #3b82f6;
    --accent-blue-bg: #eff6ff;
    --accent-pink: #ec4899;
    --accent-pink-bg: #fdf2f8;

    /* Status */
    --error: #ef4444;
    --error-bg: #fef2f2;
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
}

/* === Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

[x-cloak] { display: none !important; }

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
    text-decoration: none;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user {
    color: var(--text-muted);
    font-size: 13px;
}

.navbar-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.navbar-link:hover {
    color: var(--text);
}

/* === Main Content === */
.main-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { border-color: var(--border-hover); box-shadow: var(--shadow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* === Cards === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: box-shadow 0.15s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* === Badges / Pills === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
}

.badge-green { background: var(--accent-green-bg); color: #15803d; }
.badge-amber { background: var(--accent-amber-bg); color: #b45309; }
.badge-purple { background: var(--accent-purple-bg); color: #7e22ce; }
.badge-blue { background: var(--accent-blue-bg); color: #1d4ed8; }
.badge-pink { background: var(--accent-pink-bg); color: #be185d; }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* === Tags === */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.tag .tag-remove {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.5;
}

.tag .tag-remove:hover { opacity: 1; }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* === Toast === */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s;
}

.toast-success { background: var(--success-bg); color: #15803d; border: 1px solid #bbf7d0; }
.toast-error { background: var(--error-bg); color: var(--error); border: 1px solid #fecaca; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Utilities === */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state p {
    margin-top: 8px;
    font-size: 14px;
}

/* === Global Search Dropdown === */
.global-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 4px;
}

.global-search-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.global-search-item:last-child { border-bottom: none; }
.global-search-item:hover { background: var(--bg); }

/* === Search Results === */
.search-bar { position: relative; }
.search-input { width: 100%; }

.search-filters {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.form-input-sm { padding: 4px 10px; font-size: 13px; }

.search-results { margin-top: 16px; }

.search-result-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    background: var(--surface);
}

.search-result-item:hover { background: var(--bg); }

.search-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.search-result-stage {
    font-size: 11px;
    color: var(--text-muted);
}

.search-result-title {
    font-weight: 600;
    font-size: 14px;
}

.search-result-snippet {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.badge-sm { font-size: 10px; padding: 1px 6px; }

/* === Loading / Spinner === */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-center {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

/* === Transitions === */
.fade-enter { animation: fadeIn 0.15s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-right { animation: slideRight 0.2s ease; }

@keyframes slideRight {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar { padding: 0 16px; }
    .main-content { padding: 16px; }
    .navbar-user { display: none; }
}
