/* ============================================
   Image Repair Tool
   Dark Mode Support with Light Mode Default
   Red Theme - Repair/Recovery Focus
   ============================================ */

:root {
    --transition-speed: 0.25s;

    /* Primary Colors - Red Theme */
    --primary: #e64e4e;
    --primary-light: #fee2e2;
    --primary-dark: #c73a3a;
    --accent: #f87171;

    /* Status Colors */
    --success: #339966;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fee2e2;
    --info: #3399cc;
    --info-light: #e0f2fe;

    /* Background Colors */
    --bg: #fef7f7;
    --bg-elevated: #ffffff;
    --bg-secondary: #fee2e2;
    --bg-tertiary: #fecaca;

    /* Text Colors */
    --text: #7f1d1d;
    --text-secondary: #991b1b;
    --text-muted: #6b7280;

    /* Border */
    --border: #fecaca;
    --border-light: #fee2e2;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --input-bg: #ffffff;
    --input-border: #fecaca;
}

[data-theme="dark"] {
    --primary: #f87171;
    --primary-light: rgba(248, 113, 113, 0.15);
    --primary-dark: #ef4444;
    --accent: #fca5a5;

    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --info: #60a5fa;
    --info-light: rgba(96, 165, 250, 0.15);

    --bg: #1a1014;
    --bg-elevated: #2a1a1f;
    --bg-secondary: #3b2228;
    --bg-tertiary: #4a2a30;

    --text: #fee2e2;
    --text-secondary: #fecaca;
    --text-muted: #a8a8b3;

    --border: #4a2a30;
    --border-light: #3b2228;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);

    --input-bg: #2a1a1f;
    --input-border: #4a2a30;
}

* { box-sizing: border-box; }

/* Override custom_styles.css conflicts */
.tool-main { overflow: visible !important; }

/* ============================================
   Tool Container
   ============================================ */

.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-title {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 0.75rem;
}

.tool-description {
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.6;
}

/* ============================================
   Upload Section
   ============================================ */

.imr-upload-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
}

.imr-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    background: var(--bg);
}

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

.imr-upload-icon {
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.imr-upload-title {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.imr-upload-subtitle {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

.imr-supported-formats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.imr-format-chip {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */

.imr-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition-speed);
    text-decoration: none;
    font-family: inherit;
}

.imr-btn-primary {
    background: var(--primary) !important;
    color: #fff !important;
}

.imr-btn-primary:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-1px);
}

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

.imr-btn-ghost:hover {
    background: var(--bg-secondary) !important;
}

.imr-btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.imr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   Settings Panel
   ============================================ */

.imr-settings-panel {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.imr-settings-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1rem;
}

.imr-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.imr-settings-grid > * { min-width: 0; }

.imr-setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.imr-setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.imr-setting-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.imr-select {
    padding: 0.625rem 0.875rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
}

.imr-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   File List
   ============================================ */

.imr-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.25rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.imr-file-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.imr-file-row-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.imr-file-row-info {
    flex: 1;
    min-width: 0;
}

.imr-file-row-name {
    font-size: 0.875rem;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.imr-file-row-size {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.imr-file-row-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
}

.imr-file-row-remove:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.imr-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   Results
   ============================================ */

.imr-results {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
}

.imr-results-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.imr-result-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.imr-result-card:last-child { margin-bottom: 0; }

.imr-result-name {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
    word-break: break-word;
}

.imr-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
}

.imr-result-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text);
}

.imr-result-fixes {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.imr-result-fixes ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

.imr-result-failed {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    margin-top: 1rem;
    color: var(--danger);
    font-size: 0.9rem;
}

.imr-error-banner {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--danger);
    margin-top: 1rem;
}

.imr-error-banner a {
    color: var(--danger);
    font-weight: 600;
}

/* ============================================
   Processing Overlay
   ============================================ */

.imr-processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 1rem;
}

.imr-processing-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    min-width: 340px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.imr-stages {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
}

.imr-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.imr-stage-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: all var(--transition-speed);
}

.imr-stage.active .imr-stage-dot {
    background: var(--primary);
    color: #fff;
}

.imr-stage.done .imr-stage-dot {
    background: var(--success);
    color: #fff;
}

.imr-stage.active span,
.imr-stage.done span {
    color: var(--text);
    font-weight: 500;
}

.imr-stage-connector {
    width: 28px;
    height: 2px;
    background: var(--border);
    margin: 0 0.25rem;
    margin-bottom: 18px;
}

.imr-progress-wrap {
    margin-bottom: 0.75rem;
}

.imr-progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.imr-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.imr-progress-text {
    text-align: center;
    font-weight: 700;
    color: var(--text);
}

.imr-status-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Related Tools (horizontal pill links)
   ============================================ */

.imr-related-tools {
    max-width: 1000px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

.imr-related-tools-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.imr-related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.imr-related-label i { color: var(--primary); }

.imr-related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.imr-related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--transition-speed);
}

.imr-related-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.imr-related-link i { width: 16px; height: 16px; }

/* ============================================
   Info Sections
   ============================================ */

.imr-info-sections {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.imr-info-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.imr-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.imr-info-card h2 i { color: var(--primary); }

.imr-info-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 1rem;
}

.imr-info-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.imr-info-card a:hover { text-decoration: underline; }

.imr-bullet-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.imr-bullet-list li { margin-bottom: 0.5rem; }

.imr-bullet-list strong { color: var(--text); }

/* Steps Grid */
.imr-steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.imr-steps-grid > * { min-width: 0; }

.imr-step-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.imr-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    margin-bottom: 0.625rem;
}

.imr-step-item h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.imr-step-item p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Features Grid */
.imr-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.imr-features-grid > * { min-width: 0; }

.imr-feature-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.imr-feature-item i {
    width: 24px;
    height: 24px;
    color: var(--primary);
    margin-bottom: 0.625rem;
}

.imr-feature-item h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.imr-feature-item p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.imr-feature-item p a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.imr-feature-item p a:hover { text-decoration: underline; }

/* Error quotes grid */
.imr-errors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.imr-errors-grid > * { min-width: 0; }

.imr-error-quote {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

/* FAQ */
.imr-faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.imr-faq-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.imr-faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: transparent !important;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    font-family: inherit;
}

.imr-faq-question i {
    transition: transform var(--transition-speed);
    color: var(--text-muted);
}

.imr-faq-item.active .imr-faq-question i {
    transform: rotate(180deg);
}

.imr-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease;
}

.imr-faq-item.active .imr-faq-answer {
    max-height: 500px;
}

.imr-faq-answer p {
    padding: 0 1.25rem 1rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9rem;
}

.imr-faq-answer a {
    color: var(--primary);
    text-decoration: none;
}

.imr-faq-answer a:hover { text-decoration: underline; }

/* ============================================
   Mobile
   ============================================ */

@media (max-width: 768px) {
    .tool-container { padding: 1rem; }
    .tool-title { font-size: 1.5rem; }
    .imr-upload-section { padding: 1.25rem; }
    .imr-upload-area { padding: 2rem 1rem; }
    .imr-settings-grid { grid-template-columns: 1fr; }
    .imr-action-bar { flex-direction: column-reverse; }
    .imr-action-bar .imr-btn { width: 100%; justify-content: center; }
    .imr-related-tools { padding: 0 1rem; }
    .imr-info-sections { padding: 0 1rem 1rem; }
    .imr-info-card { padding: 1.25rem; }
    .imr-stages { flex-wrap: wrap; }
}
