/* ========================================
   eBay Template Generator - Styles
   ======================================== */

/* CSS Variables */
:root {
    --color-bg: #0f1117;
    --color-bg-elevated: #1a1d27;
    --color-bg-card: #22262f;
    --color-bg-input: #2a2f3a;
    --color-border: #3a3f4b;
    --color-border-focus: #5865f2;
    --color-text: #e4e6eb;
    --color-text-muted: #8b8f9a;
    --color-text-dim: #6b7079;
    --color-primary: #5865f2;
    --color-primary-hover: #4752c4;
    --color-accent: #f5c518;
    --color-accent-hover: #d4a915;
    --color-success: #3ba55c;
    --color-error: #ed4245;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Error UI */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: var(--color-error);
    color: white;
    text-align: center;
    z-index: 9999;
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    padding: 20px 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Phase Indicator */
.phase-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.phase {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    transition: var(--transition);
}

.phase.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.phase.completed {
    background: var(--color-bg-card);
    border-color: var(--color-success);
}

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

.phase.active .phase-number {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

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

.phase.completed .phase-number::after {
    content: '✓';
}

.phase.completed .phase-number {
    font-size: 0;
}

.phase.completed .phase-number::after {
    font-size: 0.875rem;
}

.phase-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.phase.active .phase-label {
    color: white;
}

.phase-connector {
    width: 60px;
    height: 3px;
    background: var(--color-border);
    transition: var(--transition);
}

.phase-connector.completed {
    background: var(--color-success);
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.autosave-indicator {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--color-text-dim);
    transition: var(--transition);
}

.autosave-indicator.saving {
    color: var(--color-accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn .icon {
    font-size: 1rem;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

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

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

.btn-accent {
    background: var(--color-accent);
    color: #1a1a1a;
}

.btn-accent:hover {
    background: var(--color-accent-hover);
}

.btn-large {
    padding: 14px 28px;
    font-size: 1rem;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    gap: 24px;
}

/* Form Sections */
.form-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.form-section h2 {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

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

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

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Inputs */
input[type="text"],
textarea {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-bg-input);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    background: var(--color-bg-card);
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--color-text-dim);
}

textarea {
    min-height: 100px;
    line-height: 1.6;
}

/* Character Counter */
.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--color-text-dim);
    margin-top: 4px;
}

.char-count.over-limit {
    color: var(--color-error);
    font-weight: 600;
}

/* Image Input */
.input-with-button {
    display: flex;
    gap: 12px;
}

.input-with-button input {
    flex: 1;
}

.image-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--color-bg-card);
    border-radius: var(--radius-sm);
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* Color Pickers */
.color-row {
    grid-template-columns: repeat(3, 1fr);
}

.color-picker-group .color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

input[type="color"] {
    width: 48px;
    height: 42px;
    padding: 2px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--color-bg-input);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.color-text {
    flex: 1;
    font-family: var(--font-mono) !important;
    font-size: 0.85rem !important;
    text-transform: uppercase;
}

/* Navigation Buttons */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

/* Preview Phase */
.preview-phase {
    max-width: 900px;
    margin: 0 auto;
}

.preview-container {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    overflow: hidden;
}

.preview-frame {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 20px;
    overflow: auto;
    max-height: 70vh;
}

/* HTML Phase */
.html-phase {
    max-width: 1000px;
    margin: 0 auto;
}

.html-container {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.html-toolbar {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
}

.html-code {
    margin: 0;
    padding: 24px;
    background: #0d1117;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    color: #c9d1d9;
    overflow: auto;
    max-height: 60vh;
    white-space: pre-wrap;
    word-break: break-word;
}

.html-code code {
    font-family: inherit;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    animation: slideIn 0.3s ease;
    z-index: 1000;
}

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

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

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

/* Responsive */
@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .color-row {
        grid-template-columns: 1fr;
    }
    
    .phase-indicator {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .phase-connector {
        display: none;
    }
    
    .phase {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }
    
    .app-header {
        padding: 16px;
    }
    
    .app-main {
        padding: 16px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .autosave-indicator {
        margin-left: 0;
        text-align: center;
    }
    
    .nav-buttons {
        flex-direction: column;
        gap: 12px;
    }
    
    .nav-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    .input-with-button {
        flex-direction: column;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-dim);
}
