/* Pattern Restoration Tool - Standalone Stylesheet */

/* CSS Variables */
:root {
    --pr-primary: #6366f1;
    --pr-primary-hover: #4f46e5;
    --pr-primary-light: rgba(99, 102, 241, 0.08);
    --pr-accent: #8b5cf6;
    --pr-success: #10b981;
    --pr-error: #ef4444;
    
    --pr-bg: #fafafa;
    --pr-card-bg: #ffffff;
    --pr-border: rgba(0, 0, 0, 0.08);
    --pr-text: #111827;
    --pr-text-secondary: #6b7280;
    --pr-text-muted: #9ca3af;
    
    --pr-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --pr-shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
    --pr-radius: 12px;
    --pr-radius-sm: 8px;
    
    --pr-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --pr-bg: #0f0f0f;
        --pr-card-bg: #1a1a1a;
        --pr-border: rgba(255, 255, 255, 0.1);
        --pr-text: #f3f4f6;
        --pr-text-secondary: #9ca3af;
        --pr-text-muted: #6b7280;
        --pr-primary-light: rgba(99, 102, 241, 0.15);
    }
}

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

body.standalone {
    font-family: var(--pr-font);
    background: var(--pr-bg);
    color: var(--pr-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

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

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--pr-text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--pr-text-secondary);
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0 auto;
}

.tagline-cn {
    color: var(--pr-text-muted);
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0.5rem auto 0;
}

/* Generator Container */
.generator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Panels */
.input-panel,
.output-panel {
    background: var(--pr-card-bg);
    border-radius: var(--pr-radius);
    padding: 1.5rem;
    box-shadow: var(--pr-shadow);
    border: 1px solid var(--pr-border);
}

.panel-header {
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--pr-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Upload Section */
.upload-section {
    margin-bottom: 1.25rem;
}

.upload-area {
    border: 2px dashed var(--pr-border);
    border-radius: var(--pr-radius-sm);
    transition: all 0.2s ease;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--pr-primary);
    background: var(--pr-primary-light);
}

.upload-area.drag-over {
    border-color: var(--pr-primary);
    background: var(--pr-primary-light);
    border-style: solid;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    text-align: center;
    pointer-events: none;
}

.upload-placeholder svg {
    color: var(--pr-text-muted);
    margin-bottom: 1rem;
    transition: color 0.2s ease;
}

.upload-area:hover .upload-placeholder svg {
    color: var(--pr-primary);
}

.upload-placeholder p {
    color: var(--pr-text-secondary);
    margin: 0 0 0.25rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.upload-hint {
    color: var(--pr-text-muted);
    font-size: 0.8rem;
}

/* Preview Container */
.preview-container {
    position: relative;
    width: 100%;
}

.preview-container img {
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    display: block;
}

.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.remove-image-btn:hover {
    background: var(--pr-error);
    transform: scale(1.1);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--pr-primary);
    color: white;
    border: none;
    border-radius: var(--pr-radius-sm);
    font-family: var(--pr-font);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-btn:hover:not(:disabled) {
    background: var(--pr-primary-hover);
}

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

.generate-btn .btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

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

/* Output Area */
.output-area {
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--pr-border);
    border-radius: var(--pr-radius-sm);
    overflow: hidden;
}

.output-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.output-placeholder svg {
    color: var(--pr-text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.output-placeholder p {
    color: var(--pr-text-muted);
    margin: 0;
    font-size: 0.9rem;
}

/* Timer Display */
.timer-display {
    color: var(--pr-primary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.75rem;
    font-variant-numeric: tabular-nums;
}

/* Output Result */
.output-result {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.output-result img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

.output-actions {
    display: flex;
    justify-content: center;
    padding: 0.75rem;
    background: var(--pr-primary-light);
    border-top: 1px solid var(--pr-border);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: var(--pr-primary);
    color: white;
    font-family: var(--pr-font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--pr-primary-hover);
}

/* Success Message */
.success-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.8rem;
}

.success-message .success-text {
    color: #3b82f6;
    font-weight: 500;
}

.success-message .time-text {
    color: var(--pr-text-muted);
    font-variant-numeric: tabular-nums;
}

/* Output Error */
.output-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.output-error svg {
    color: var(--pr-error);
    margin-bottom: 0.75rem;
}

.output-error p {
    color: var(--pr-error);
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.retry-btn {
    padding: 0.5rem 1.25rem;
    background: var(--pr-error);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: var(--pr-font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-btn:hover {
    background: #dc2626;
}

/* Loading Animation */
.output-area.loading {
    background: linear-gradient(
        90deg,
        var(--pr-primary-light) 25%,
        transparent 50%,
        var(--pr-primary-light) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.25rem;
    background: var(--pr-text);
    color: white;
    border-radius: var(--pr-radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { background: var(--pr-success); }
.toast.error { background: var(--pr-error); }

/* Responsive */
@media (max-width: 700px) {
    .app-container {
        padding: 2rem 1rem;
    }
    
    .generator-container {
        grid-template-columns: 1fr;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
}
