/* ===== CSS Custom Properties / Design Tokens ===== */
:root {
    --color-primary: #2980b9;
    --color-primary-hover: #2471a3;
    --color-primary-light: #e3f2fd;
    --color-danger: #e74c3c;
    --color-danger-light: #f1948a;
    --color-danger-bg: rgba(231, 76, 60, 0.12);
    --color-success: #27ae60;
    --color-success-hover: #219a52;
    --color-orange: #e67e22;
    --color-convert: #7f8c8d;
    --color-convert-hover: #6c7a7b;
    --color-bg: #f0f4f8;
    --color-white: #ffffff;
    --color-text-primary: #2c3e50;
    --color-text-secondary: #555555;
    --color-text-muted: #95a5a6;
    --color-border: #e0e6ed;
    --color-border-light: #eef2f7;
    --color-dropzone-border: #a8c8e0;
    --color-dropzone-active: #2980b9;
    --color-badge-bg: #f5f7fa;
    --color-badge-active: #2c3e50;
    --color-badge-text: #7f8c8d;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 2px 20px rgba(41, 128, 185, 0.08), 0 1px 6px rgba(0, 0, 0, 0.04);
    --shadow-btn: 0 2px 8px rgba(41, 128, 185, 0.2);
    --transition: 0.2s ease;
    --max-width: 960px;
}

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

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

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--font-family);
}

ul {
    list-style: none;
}

/* ===== Header ===== */
.header {
    background: var(--color-white);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.header-inner {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    flex-shrink: 0;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-full {
    color: var(--color-text-primary);
}

.logo-converter {
    color: var(--color-orange);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all var(--transition);
}

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

.nav-link.active {
    color: var(--color-orange);
    font-weight: 600;
}

/* ===== Language Selector ===== */
.header-lang {
    display: flex;
    align-items: center;
}

.lang-selector {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--color-text-secondary);
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition);
    outline: none;
}

.lang-selector:hover,
.lang-selector:focus {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ===== Accent Line ===== */
.accent-line {
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-orange), var(--color-danger));
}

/* ===== Main ===== */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    margin-bottom: 36px;
}

.hero h1 {
    font-size: 38px;
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--color-text-secondary);
    max-width: 740px;
    margin: 0 auto 20px;
    line-height: 1.7;
}

.hero-instructions {
    display: inline-flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.hero-instructions li {
    font-size: 15px;
    color: var(--color-text-secondary);
    padding-left: 20px;
    position: relative;
}

.hero-instructions li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--color-primary);
    font-weight: 700;
}

/* ===== Tool Container ===== */
.tool-container {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 60px;
}


/* Uniform button sizing for SELECT FILES & CLEAR */
.btn-uniform {
    min-width: 180px;
    justify-content: center;
}

/* Disabled-initial state: grayed out until files are loaded */
.disabled-initial {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

/* Tool Content */
.tool-content {
    padding: 28px 32px 32px;
}

/* Control Bar */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    transition: all var(--transition);
    cursor: pointer;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(41, 128, 185, 0.3);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: none;
    box-shadow: inset 0 0 0 1.5px var(--color-danger-light);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: var(--color-white);
    box-shadow: inset 0 0 0 1.5px var(--color-danger);
}

.btn-convert {
    background: var(--color-convert);
    color: var(--color-white);
    padding: 12px 32px;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(127, 140, 141, 0.25);
}

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

.btn-convert.ready {
    background: var(--color-primary);
    box-shadow: var(--shadow-btn);
}

.btn-convert.ready:hover {
    background: var(--color-primary-hover);
}

.btn-convert.save-all {
    background: var(--color-success);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.btn-convert.save-all:hover {
    background: var(--color-success-hover);
}

.btn-convert.converting {
    background: var(--color-primary);
    pointer-events: none;
    opacity: 0.85;
}

/* ===== Drop Zone ===== */
.dropzone-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.carousel-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--color-danger-light);
    background: transparent;
    transition: all var(--transition);
    flex-shrink: 0;
    line-height: 1;
    padding-bottom: 2px;
}

.carousel-arrow:hover {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.dropzone {
    flex: 1;
    min-height: 200px;
    border: 2.5px dashed var(--color-dropzone-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

.dropzone.has-files {
    border: none;
    min-height: auto;
    overflow: hidden;
}

.dropzone.drag-over {
    border-color: var(--color-dropzone-active);
    background: var(--color-primary-light);
    box-shadow: inset 0 0 30px rgba(41, 128, 185, 0.08);
}

.dropzone-text {
    font-size: 17px;
    font-weight: 500;
    color: var(--color-dropzone-border);
    pointer-events: none;
    user-select: none;
}

/* ===== File Grid (replacing carousel) ===== */
#file-carousel {
    width: 100%;
    position: relative;
}

.file-grid {
    width: 100%;
    display: flex;
    gap: 12px;
    padding: 12px 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.file-grid::-webkit-scrollbar {
    display: none;
}

/* Checkered background pattern */
.checkerboard-bg {
    background-image:
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
        linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #f5f5f5;
}

/* File Card */
.file-card {
    position: relative;
    width: 170px;
    min-width: 170px;
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid var(--color-border-light);
    background: var(--color-white);
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.file-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Filename header bar (includes close button) */
.file-card-header {
    display: flex;
    align-items: center;
    background: rgba(245, 247, 250, 0.95);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0;
    min-height: 30px;
}

.file-card-name {
    flex: 1;
    min-width: 0;
    padding: 5px 4px 5px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Close button inside header bar */
.file-card-close {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    color: var(--color-text-muted);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    border-left: 1px solid var(--color-border-light);
    border-radius: 0;
}

.file-card-close:hover {
    background: var(--color-danger);
    color: var(--color-white);
}

/* Card thumbnail area */
.file-card-thumb-wrap {
    position: relative;
    width: 100%;
    height: 140px;
    overflow: hidden;
}

.file-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Format label overlay centered on thumbnail */
.file-card-format-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 22px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.95);
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 1;
}

/* SAVE button at bottom of card */
.file-card-save {
    display: none;
    width: 100%;
    padding: 8px 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(39, 174, 96, 0.15);
    color: var(--color-success);
    border: none;
    border-top: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: all var(--transition);
}

.file-card-save.visible {
    display: block;
}

.file-card-save:hover {
    background: var(--color-success);
    color: var(--color-white);
}

/* File count badge on convert button */
.convert-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
    position: relative;
    top: -1px;
}

/* ===== Bottom Bar ===== */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.format-badges {
    display: flex;
    gap: 6px;
}

.format-badge {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid var(--color-border);
    color: var(--color-badge-text);
    background: var(--color-badge-bg);
    transition: all var(--transition);
}

.format-badge:hover:not(.disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.format-badge.active {
    background: var(--color-badge-active);
    color: var(--color-white);
    border-color: var(--color-badge-active);
}

.format-badge.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Status Bar */
.status-bar {
    text-align: center;
    margin-top: 16px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
}

/* ===== Converting Spinner ===== */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* ===== Info Content ===== */
.info-content {
    padding: 20px 0;
}

.info-content h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.info-content h3 {
    font-size: 21px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 32px 0 12px;
}

.info-content h4 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 20px 0 8px;
}

.info-content p {
    font-size: 15px;
    color: var(--color-text-secondary);
    line-height: 1.75;
    margin-bottom: 12px;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.format-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition);
}

.format-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.format-card h4 {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--color-primary);
}

.format-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    padding: 28px 24px;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-security {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-success);
}

.footer-copy {
    font-size: 13px;
    color: var(--color-text-muted);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.footer-links a {
    color: var(--color-text-muted);
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--color-primary);
}

.footer-sep {
    color: var(--color-text-muted);
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .hero h1 {
        font-size: 24px;
    }

    .header {
        padding: 0 16px;
    }

    .header-nav {
        gap: 4px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }

    .main {
        padding: 24px 16px 40px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .tool-content {
        padding: 20px 16px 24px;
    }

    .control-bar {
        gap: 10px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 12px;
    }

    .file-card {
        flex-direction: column;
        padding: 16px 20px;
        gap: 12px;
    }

    .file-thumb {
        width: 80px;
        height: 80px;
    }

    .file-info {
        text-align: center;
        width: 100%;
    }

    .file-meta {
        justify-content: center;
    }

    .file-actions {
        align-items: center;
    }

    .format-badge {
        padding: 8px 14px;
        font-size: 12px;
    }

    .bottom-bar {
        gap: 14px;
    }

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

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .dropzone {
        min-height: 150px;
    }

    .carousel-arrow {
        width: 28px;
        height: 28px;
        font-size: 24px;
    }

    .format-badges {
        justify-content: center;
    }

    .btn-convert {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 18px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .control-bar {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .bottom-bar {
        flex-direction: column;
    }

    .format-badges {
        justify-content: center;
    }

    .btn-convert {
        width: 100%;
        justify-content: center;
    }
}

/* ============================
   MODALS
   ============================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--color-white);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.2s;
    z-index: 2;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-content {
    padding: 30px;
    overflow-y: auto;
    color: var(--color-text-secondary);
}

.modal-content h2 {
    color: var(--color-primary);
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 800;
}

.modal-content h3 {
    color: var(--color-text);
    font-size: 18px;
    margin-top: 24px;
    margin-bottom: 12px;
}

.modal-content p,
.modal-content li {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 12px;
}

.modal-content ol {
    margin: 0;
    padding-left: 20px;
}