/* ===== VARIABLES & RESET ===== */
:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #1a1a24;
    --bg-panel-hover: #24243a;
    --border-color: #2a2a3e;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --sidebar-width: 340px;
    --header-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ===== LAYOUT ===== */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "header header"
        "sidebar canvas";
    height: 100vh;
    width: 100vw;
}

.app-container.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

/* ===== HEADER ===== */
.app-header {
    grid-area: header;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.linkedin-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.linkedin-share-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.linkedin-share-btn:hover {
    background: rgba(80, 200, 120, 0.1);
    border-color: rgba(80, 200, 120, 0.5);
    color: #50C878;
}

#status-container {
    padding: 8px 16px;
    background: var(--bg-panel-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

#status-container:not([hidden]) {
    display: flex;
}

/* ===== SIDEBAR ===== */
.app-sidebar {
    grid-area: sidebar;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
    opacity: 0;
}

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

/* ===== WORKFLOW STEPS ===== */
.workflow-step {
    position: relative;
}

.workflow-step::before {
    content: '';
    position: absolute;
    left: 38px;
    top: 60px;
    bottom: -1px;
    width: 2px;
    background: var(--border-color);
    z-index: 0;
}

.workflow-step:last-of-type::before {
    display: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.step-badge {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.step-badge-active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.step-badge-completed {
    background: var(--accent-success);
    color: white;
}

.step-badge-disabled {
    background: var(--bg-panel-hover);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.step-info {
    flex: 1;
}

.step-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.step-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.workflow-step[data-disabled="true"] .form-group,
.workflow-step[data-disabled="true"] .btn-group,
.workflow-step[data-disabled="true"] .playback-controls {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== ADVANCED SETTINGS ===== */
.advanced-settings {
    margin: 20px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
}

.advanced-settings-toggle {
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    list-style: none;
}

.advanced-settings-toggle::-webkit-details-marker {
    display: none;
}

.advanced-settings-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-panel-hover);
}

.advanced-settings[open] .advanced-settings-toggle {
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-primary);
}

.advanced-settings-content {
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* ===== FORM CONTROLS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="text"]:disabled,
input[type="password"]:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Range Sliders */
input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.slider-value {
    display: inline-block;
    min-width: 45px;
    padding: 4px 8px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    text-align: center;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-control input[type="range"] {
    flex: 1;
}

/* Buttons */
button {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ===== CANVAS CONTAINER ===== */
.canvas-wrapper {
    grid-area: canvas;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #14141f 0%, var(--bg-dark) 100%);
    position: relative;
    overflow: hidden;
}

#canvas-container {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    background: #ffffff;
    position: relative;
}

/* Canvas animation overlay */
.canvas-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 36, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow-md);
}

.canvas-overlay button {
    padding: 8px 16px;
    font-size: 13px;
}

/* ===== PLAYBACK CONTROLS ===== */
.playback-controls {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.playback-controls button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
}

/* ===== UTILITIES ===== */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

[hidden] {
    display: none !important;
}

/* ===== SCROLLBAR ===== */
.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "canvas";
    }

    .app-sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: 90vw;
        max-width: 320px;
        z-index: 50;
        transform: translateX(-100%);
    }

    .app-container:not(.sidebar-collapsed) .app-sidebar {
        transform: translateX(0);
    }

    .canvas-overlay {
        bottom: 10px;
        padding: 8px 12px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-section {
    animation: fadeIn 0.3s ease-out;
}

/* ===== LOADING OVERLAY ===== */
.canvas-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 10;
    border-radius: var(--radius-md);
}

.canvas-loader.active {
    display: flex;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-content {
    text-align: center;
    color: #333;
}

.loader-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a1a24;
}

.loader-subtitle {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.loader-progress {
    width: 200px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 16px;
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #ec4899);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loader-progress-bar.indeterminate {
    width: 40%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

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

/* ===== PROVIDER TABS ===== */
.provider-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.provider-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    margin-bottom: -2px;
}

.provider-tab:hover {
    color: var(--text-primary);
    background: var(--bg-panel-hover);
}

.provider-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.provider-tab.configured::after {
    content: '●';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 8px;
    color: var(--accent-success);
}

.provider-content {
    display: none;
}

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

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(250%);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* Dots animation for loading text */
.loader-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ===== DEBUG OVERLAY ===== */
.debug-overlay {
    position: fixed;
    top: 80px;
    left: 360px;
    background: rgba(26, 26, 36, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    max-width: 280px;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 200;
}

.sidebar-collapsed .debug-overlay {
    left: 20px;
}

.debug-overlay.active {
    display: block;
}

.debug-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.debug-title::before {
    content: '🔍';
    font-size: 16px;
}

.debug-info {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.debug-info strong {
    color: var(--text-primary);
}

.debug-actions {
    display: flex;
    gap: 8px;
}

.debug-actions button {
    flex: 1;
    font-size: 12px;
    padding: 8px 12px;
}

/* ===== CACHE MANAGEMENT ===== */
.cache-list {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-height: 400px;
    overflow-y: auto;
}

.cache-count {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.cache-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cache-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.cache-entry:hover {
    background: var(--bg-panel-hover);
    border-color: var(--accent-primary);
}

.cache-entry-info {
    flex: 1;
    min-width: 0;
}

.cache-entry-prompt {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.cache-entry-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.cache-entry-delete {
    padding: 6px 12px;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.cache-entry-delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}
