/* Material Design 3 Color Tokens */
:root {
    /* Primary */
    --md-sys-color-primary: #1976D2;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #D3E4FD;
    --md-sys-color-on-primary-container: #001C38;

    /* Secondary */
    --md-sys-color-secondary: #00897B;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #B2DFDB;
    --md-sys-color-on-secondary-container: #002019;

    /* Surface */
    --md-sys-color-surface: #FEFBFF;
    --md-sys-color-on-surface: #1A1C1E;
    --md-sys-color-surface-variant: #E1E2EC;
    --md-sys-color-on-surface-variant: #44474F;
    --md-sys-color-surface-container-low: #F6F2F7;
    --md-sys-color-surface-container: #F0EDF1;
    --md-sys-color-surface-container-high: #EBE7EC;

    /* Background */
    --md-sys-color-background: #FEFBFF;
    --md-sys-color-on-background: #1A1C1E;

    /* Outline */
    --md-sys-color-outline: #74777F;
    --md-sys-color-outline-variant: #C4C6D0;

    /* Success */
    --md-sys-color-success: #2E7D32;
    --md-sys-color-on-success: #FFFFFF;
    --md-sys-color-success-container: #C8E6C9;

    /* Warning */
    --md-sys-color-warning: #F57C00;
    --md-sys-color-on-warning: #FFFFFF;
    --md-sys-color-warning-container: #FFE0B2;

    /* Error */
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;

    /* Elevation Shadows */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-4: 0 2px 3px 0 rgba(0, 0, 0, 0.3), 0 6px 10px 4px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-5: 0 4px 4px 0 rgba(0, 0, 0, 0.3), 0 8px 12px 6px rgba(0, 0, 0, 0.15);

    /* State Layers */
    --md-sys-state-hover-opacity: 0.08;
    --md-sys-state-focus-opacity: 0.12;
    --md-sys-state-pressed-opacity: 0.12;
}

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

/* Material Typography */
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--md-sys-color-surface-container-low);
    min-height: 100vh;
    padding: 16px;
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
}

/* Material Top App Bar */
.md-top-app-bar {
    background: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-2);
    padding: 16px 24px;
    border-radius: 16px 16px 0 0;
    margin-bottom: 0;
}

/* Container */
.container {
    max-width: 840px;
    margin: 24px auto;
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-2);
}

.container-content {
    padding: 24px;
}

/* Material Typography Scale */
.md-typescale-headline-small {
    font-size: 24px;
    font-weight: 400;
    line-height: 32px;
    letter-spacing: 0;
    color: var(--md-sys-color-on-surface);
}

.md-typescale-title-medium {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0.15px;
    color: var(--md-sys-color-on-surface);
}

.md-typescale-body-medium {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    letter-spacing: 0.25px;
    color: var(--md-sys-color-on-surface-variant);
}

.md-typescale-label-large {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: 0.1px;
}

/* Material Icons */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* Material Card - Upload Area */
.upload-area {
    border: 2px dashed var(--md-sys-color-outline);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    background: var(--md-sys-color-surface-container);
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--md-sys-color-on-surface);
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
    pointer-events: none;
}

.upload-area:hover::before {
    opacity: var(--md-sys-state-hover-opacity);
}

.upload-area:active::before {
    opacity: var(--md-sys-state-pressed-opacity);
}

.upload-area.uploaded {
    background: var(--md-sys-color-success-container);
    border-color: var(--md-sys-color-success);
}

.upload-area.uploaded .upload-icon {
    color: var(--md-sys-color-success);
}

.upload-area.dragover {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--md-sys-color-on-surface-variant);
}

input[type="file"] {
    display: none;
}

.file-name-display {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--md-sys-color-surface);
    border-radius: 8px;
    font-size: 14px;
    color: var(--md-sys-color-success);
    font-weight: 500;
    display: none;
    box-shadow: var(--md-sys-elevation-1);
}

.file-name-display.show {
    display: inline-block;
}

/* Material Card */
.result-card {
    background: var(--md-sys-color-surface-container);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    display: none;
    box-shadow: var(--md-sys-elevation-1);
}

.result-card.show {
    display: block;
    animation: slideIn 300ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    background: var(--md-sys-color-surface);
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

/* Material Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.badge.success {
    background: var(--md-sys-color-success-container);
    color: var(--md-sys-color-success);
}

.badge.warning {
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-warning);
}

.badge.info {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-primary);
}

/* Material Filled Button */
button {
    position: relative;
    padding: 10px 24px;
    border: none;
    border-radius: 20px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
    min-height: 40px;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
}

button:hover::before {
    opacity: var(--md-sys-state-hover-opacity);
}

button:active::before {
    opacity: var(--md-sys-state-pressed-opacity);
}

button.primary {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-1);
}

button.primary:hover {
    box-shadow: var(--md-sys-elevation-2);
}

button.secondary {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none;
}

button:disabled::before {
    display: none;
}

/* Material Expansion Panel */
.advanced-options {
    margin-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    padding-top: 16px;
}

.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 16px;
    background: var(--md-sys-color-surface-container);
    border-radius: 12px;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.advanced-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--md-sys-color-on-surface);
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
}

.advanced-toggle:hover::before {
    opacity: var(--md-sys-state-hover-opacity);
}

.advanced-toggle-icon {
    font-size: 20px;
    transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
    color: var(--md-sys-color-on-surface-variant);
}

.advanced-toggle-icon.expanded {
    transform: rotate(90deg);
}

.advanced-toggle-text {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    letter-spacing: 0.1px;
}

.advanced-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms cubic-bezier(0.2, 0, 0, 1);
}

.advanced-content.expanded {
    max-height: 1000px;
}

/* Material Radio Buttons */
.encoding-options {
    margin-top: 16px;
    background: var(--md-sys-color-surface);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.encoding-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 200ms cubic-bezier(0.2, 0, 0, 1);
    min-height: 48px;
}

.encoding-option:hover {
    background: rgba(var(--md-sys-color-on-surface), var(--md-sys-state-hover-opacity));
}

.encoding-option input[type="radio"] {
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: var(--md-sys-color-primary);
}

.encoding-option label {
    cursor: pointer;
    flex: 1;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    letter-spacing: 0.25px;
}

.download-btn-container {
    margin-top: 16px;
}

.download-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    box-shadow: var(--md-sys-elevation-1);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download-btn:hover {
    box-shadow: var(--md-sys-elevation-2);
}

/* Material Snackbar-style Message */
.perfect-file-msg {
    margin-top: 16px;
    padding: 16px;
    background: var(--md-sys-color-success-container);
    border-left: 4px solid var(--md-sys-color-success);
    border-radius: 12px;
    display: none;
    box-shadow: var(--md-sys-elevation-1);
}

.perfect-file-msg.show {
    display: block;
    animation: slideIn 300ms cubic-bezier(0.2, 0, 0, 1);
}

.perfect-file-msg .msg-title {
    font-weight: 500;
    color: var(--md-sys-color-success);
    margin-bottom: 8px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.perfect-file-msg .msg-content {
    color: var(--md-sys-color-on-success-container);
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: 0.25px;
}

/* Unsupported File Message */
.unsupported-file-msg {
    margin-top: 16px;
    padding: 16px;
    background: var(--md-sys-color-primary-container);
    border-left: 4px solid var(--md-sys-color-primary);
    border-radius: 12px;
    display: none;
    box-shadow: var(--md-sys-elevation-1);
}

.unsupported-file-msg.show {
    display: block;
    animation: slideIn 300ms cubic-bezier(0.2, 0, 0, 1);
}

.unsupported-file-msg .msg-title {
    font-weight: 500;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unsupported-file-msg .msg-content {
    color: var(--md-sys-color-on-primary-container);
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: 0.25px;
}

.unsupported-file-msg .msg-content strong {
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

/* Material Filled Select */
#testFileSelect {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px 4px 0 0;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface-container);
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    border-bottom: 2px solid var(--md-sys-color-outline);
    letter-spacing: 0.5px;
}

#testFileSelect:hover {
    background: var(--md-sys-color-surface-container-high);
    border-bottom-color: var(--md-sys-color-on-surface);
}

#testFileSelect:focus {
    outline: none;
    border-bottom-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container-high);
}

.test-file-section {
    margin-bottom: 24px;
}

.section-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
    letter-spacing: 0.1px;
}

/* Footer & Features */
.md-footer {
    /* margin-top: 48px; */
    padding: 32px 0 24px;
    text-align: center;
}

.features-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-bottom: 32px;
    text-align: left;
    padding-right: 24px;
    padding-left: 24px;
}

.feature-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon .material-symbols-outlined {
    font-size: 24px;
}

.feature-text h3 {
    margin: 0 0 4px;
    color: var(--md-sys-color-on-surface);
}

.feature-text p {
    margin: 0;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
}

.footer-divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    margin: 0 auto 16px;
    width: 100%;
}

.footer-copyright {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.7;
}

@media (max-width: 600px) {
    .features-section {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}