/* ============================================
   Ugoira Converter - Modern Styling with Dark Mode
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;

    /* Primary Colors */
    --primary: #3399cc;
    --primary-light: #E0F2FE;
    --primary-dark: #2b82ad;
    --accent: #38BDF8;

    /* ConvertICO Colors */
    --color-1: #e64e4e;
    --color-2: #3399cc;
    --color-3: #339966;

    /* Status Colors */
    --success: #339966;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #e64e4e;
    --danger-light: #FEE2E2;
    --info: #3399cc;
    --info-light: #DBEAFE;

    /* Format Colors */
    --gif-color: #e64e4e;
    --mp4-color: #3399cc;
    --webm-color: #339966;

    /* Background Colors */
    --bg: #F8FAFC;
    --bg-elevated: #FFFFFF;
    --bg-secondary: #F1F5F9;
    --bg-tertiary: #E2E8F0;

    /* Text Colors */
    --text: #1E293B;
    --text-secondary: #475569;
    --text-muted: #64748B;

    /* Border Colors */
    --border: #E2E8F0;
    --border-light: #F1F5F9;

    /* 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);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --shadow-primary: 0 4px 14px rgba(51, 153, 204, 0.25);
    --shadow-primary-hover: 0 6px 20px rgba(51, 153, 204, 0.35);

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

    /* Checkerboard for transparency */
    --checker-light: #f0f0f0;
    --checker-dark: #e0e0e0;

    /* Input */
    --input-bg: #FFFFFF;
    --input-border: #E2E8F0;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --primary: #38BDF8;
    --primary-light: rgba(56, 189, 248, 0.15);
    --primary-dark: #0EA5E9;
    --accent: #7DD3FC;

    --success: #4ADE80;
    --success-light: rgba(74, 222, 128, 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);

    --gif-color: #F87171;
    --mp4-color: #60A5FA;
    --webm-color: #4ADE80;

    --bg: #0F172A;
    --bg-elevated: #1E293B;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;

    --text: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;

    --border: #334155;
    --border-light: #475569;

    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5);
    --shadow-primary: 0 4px 14px rgba(56, 189, 248, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(56, 189, 248, 0.3);

    --checker-light: #334155;
    --checker-dark: #2a3a50;

    --input-bg: #1E293B;
    --input-border: #475569;
}

/* ============================================
   Base Styles
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

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

.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* ============================================
   Tool Header
   ============================================ */

.tool-header {
    text-align: center;
    margin-bottom: 30px;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

.tool-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.tool-icon-wrapper svg {
    width: 26px;
    height: 26px;
}

.tool-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.5px;
}

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

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

.upload-section {
    margin-bottom: 20px;
}

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

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

.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.01);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    color: var(--text-muted);
    transition: color var(--transition-speed);
}

.upload-area:hover .upload-icon {
    color: var(--primary);
}

.upload-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.upload-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

.file-types {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.file-type-badge {
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}

.upload-note {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 12px;
    line-height: 1.5;
}

.upload-note svg {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ============================================
   File Info Bar
   ============================================ */

.file-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 14px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.file-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.file-info-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ============================================
   Editor Layout
   ============================================ */

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

/* Preview Panel */
.preview-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preview-wrapper {
    position: relative;
}

.preview-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain;
    background-image: linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
                      linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
                      linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: var(--checker-dark);
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.preview-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: all var(--transition-speed);
}

.preview-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.frame-counter {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.control-label svg {
    color: var(--primary);
}

/* Format Options */
.format-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.format-option input {
    display: none;
}

.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
}

.format-option input:checked + .format-card {
    border-color: var(--primary);
    background: var(--primary-light);
}

.format-card:hover {
    border-color: var(--primary);
}

.format-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.format-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* Delay Controls */
.delay-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delay-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.delay-option input[type="radio"] {
    accent-color: var(--primary);
}

.custom-delay-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.styled-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.styled-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    min-width: 50px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.delay-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Output Summary */
.output-summary {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
    flex: 1;
}

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

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

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

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

.processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.processing-content {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 40px 50px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    width: 90%;
}

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

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

.processing-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 20px;
}

.progress-bar-wrapper {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

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

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

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

.result-preview {
    padding: 20px;
    display: flex;
    justify-content: center;
    background-image: linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
                      linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
                      linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: var(--checker-dark);
}

.result-preview img,
.result-preview video {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius-sm);
}

.result-info {
    padding: 16px 20px;
    display: flex;
    gap: 24px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.result-info-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.result-label {
    color: var(--text-muted);
}

.result-value {
    font-weight: 600;
    color: var(--text);
}

.result-actions {
    padding: 16px 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================
   Error Message
   ============================================ */

.error-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    margin-top: 16px;
    color: var(--danger);
}

.error-message > svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.error-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.error-contact {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.error-contact a {
    color: var(--primary);
    text-decoration: underline;
}

.error-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--danger);
    opacity: 0.7;
    transition: opacity var(--transition-speed);
    flex-shrink: 0;
}

.error-close:hover {
    opacity: 1;
}

/* ============================================
   Related Tools
   ============================================ */

.related-tools-section {
    margin-top: 40px;
    margin-bottom: 30px;
}

.related-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 16px;
}

.related-title svg {
    color: var(--primary);
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-speed);
}

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

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

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

.info-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 20px;
}

.info-card {
    padding: 0;
}

.info-card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 16px;
}

.info-card h2 svg {
    color: var(--primary);
    flex-shrink: 0;
}

.info-card p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 12px;
}

.info-card p:last-child {
    margin-bottom: 0;
}

.info-card a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.info-card a:hover {
    color: var(--primary-dark);
}

/* Steps List */
.steps-list {
    margin: 0;
    padding: 0 0 0 24px;
    counter-reset: step;
}

.steps-list li {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 10px;
    padding-left: 4px;
}

.steps-list li:last-child {
    margin-bottom: 0;
}

/* Mode Explanations */
.mode-explanations {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mode-explain {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mode-tag {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.mode-tag.format-gif {
    background: rgba(230, 78, 78, 0.12);
    color: var(--gif-color);
}

.mode-tag.format-mp4 {
    background: rgba(51, 153, 204, 0.12);
    color: var(--mp4-color);
}

.mode-tag.format-webm {
    background: rgba(51, 153, 102, 0.12);
    color: var(--webm-color);
}

.mode-explain p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   FAQ Section
   ============================================ */

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    transition: background var(--transition-speed);
}

.faq-question:hover {
    background: var(--bg-secondary);
}

.faq-question svg {
    color: var(--text-muted);
    transition: transform var(--transition-speed);
    flex-shrink: 0;
}

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

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

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

.faq-answer p {
    padding: 0 16px 14px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .tool-container {
        padding: 20px 14px 40px;
    }

    .tool-title {
        font-size: 24px;
    }

    .tool-description {
        font-size: 14px;
    }

    .upload-area {
        padding: 30px 20px;
    }

    .file-info-bar {
        gap: 10px;
    }

    .format-options {
        grid-template-columns: 1fr;
    }

    .quality-options {
        grid-template-columns: repeat(3, 1fr);
    }

    .action-buttons {
        flex-direction: column;
    }

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

    .result-info {
        flex-direction: column;
        gap: 8px;
    }

    .output-summary {
        gap: 8px;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
