/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px;
    --transition: all 0.2s ease;
}

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

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

/* ===== Layout ===== */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== Header ===== */
.app-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ===== Steps Indicator ===== */
.steps-indicator {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 2.5rem;
    position: relative;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    position: relative;
}

.step-item:not(:last-child)::after {
    content: '';
    width: 40px;
    height: 2px;
    background: var(--border);
    display: block;
}

.step-item.active .step-number {
    background: var(--primary);
    color: white;
}

.step-item.completed .step-number {
    background: var(--success);
    color: white;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.step-label {
    font-size: 0.825rem;
    color: var(--text-light);
    white-space: nowrap;
}

.step-item.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.step-item.completed .step-label {
    color: var(--success);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title .icon {
    font-size: 1.3rem;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
}

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

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

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

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===== File Upload ===== */
.file-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.file-upload-zone:hover,
.file-upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-zone .upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.file-upload-zone .upload-text {
    font-size: 0.9rem;
    color: var(--text-light);
}

.file-upload-zone .upload-text strong {
    color: var(--primary);
}

.file-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--primary-light);
    border-radius: 8px;
    margin-top: 0.75rem;
}

.file-info .file-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.file-info .file-size {
    font-size: 0.8rem;
    color: var(--text-light);
}

.file-info .file-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

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

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

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

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

.btn-success:hover {
    opacity: 0.9;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ===== Progress Section ===== */
.progress-container {
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-bar-wrapper {
    background: var(--border);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-phases {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.phase-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--bg);
    font-size: 0.9rem;
}

.phase-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.phase-item.completed {
    background: #f0fdf4;
    color: var(--success);
}

.phase-item.error {
    background: #fef2f2;
    color: var(--danger);
}

.phase-icon {
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Preview Section ===== */
.preview-container {
    display: none;
}

.preview-container.active {
    display: block;
}

.preview-content {
    max-height: 600px;
    overflow-y: auto;
    padding: 2rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.8;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.preview-content th,
.preview-content td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
}

.preview-content th {
    background: var(--bg);
    font-weight: 600;
}

/* Placeholder highlighting */
.placeholder-highlight {
    background: #fef3c7;
    border: 1px solid var(--warning);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 500;
    color: #92400e;
}

/* ===== Download Section ===== */
.download-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ===== Sections Visibility ===== */
.section-panel {
    display: none;
}

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

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #1e293b; }

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .steps-indicator {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .step-item:not(:last-child)::after {
        display: none;
    }

    .btn-group {
        flex-direction: column;
    }

    .download-actions {
        flex-direction: column;
    }
}

/* ===== Loading overlay ===== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-card .spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
    margin-bottom: 1rem;
}
