/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    min-height: 100vh;
}

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

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

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    background: linear-gradient(135deg, #58a6ff, #bc8cff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #8b949e;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* ==========================================================================
   Format Tabs
   ========================================================================== */

.format-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 0.25rem;
    width: fit-content;
}

.format-tabs .tab {
    padding: 0.45rem 1.4rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #8b949e;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.format-tabs .tab:hover {
    color: #e1e4e8;
}

.format-tabs .tab.active {
    background: #58a6ff;
    color: #fff;
}

/* --- Format warning --- */

.format-warning {
    background: #3d1214;
    border: 1px solid #da3633;
    color: #f85149;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.format-warning.hidden {
    display: none;
}

/* ==========================================================================
   Dropzone
   ========================================================================== */

.dropzone {
    border: 2px dashed #30363d;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #161b22;
    margin-bottom: 1.5rem;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: #58a6ff;
    background: #1a2233;
}

.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
}

.dropzone-text {
    font-size: 1rem;
    color: #8b949e;
}

.dropzone-text strong {
    color: #58a6ff;
}

.dropzone-formats {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.dropzone input {
    display: none;
}

/* ==========================================================================
   Controls (shared)
   ========================================================================== */

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.control-group label {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-value {
    font-size: 0.8rem;
    color: #58a6ff;
    min-width: 35px;
    text-align: right;
}

/* --- Inputs --- */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #30363d;
    border-radius: 3px;
    outline: none;
    width: 140px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #58a6ff;
    border-radius: 50%;
    cursor: pointer;
}

input[type="number"],
select {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e1e4e8;
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    width: 70px;
    font-size: 0.85rem;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #58a6ff;
}

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

.btn {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary            { background: #238636; color: #fff; }
.btn-primary:hover      { background: #2ea043; }
.btn-secondary          { background: #21262d; color: #c9d1d9; border: 1px solid #30363d; }
.btn-secondary:hover    { background: #30363d; }
.btn-danger             { background: #da3633; color: #fff; }
.btn-danger:hover       { background: #f85149; }
.btn-apply-all          { background: #1f6feb; color: #fff; }
.btn-apply-all:hover    { background: #388bfd; }
.btn:disabled           { opacity: 0.5; cursor: not-allowed; }

.btn-icon {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.15s;
}

.btn-icon:hover         { color: #e1e4e8; background: #21262d; }
.btn-icon.delete:hover  { color: #f85149; }

/* ==========================================================================
   Global Controls Bar
   ========================================================================== */

.global-controls {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
    display: none;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
}

.global-controls.visible {
    display: flex;
}

.global-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: end;
}

/* ==========================================================================
   Image List & Cards
   ========================================================================== */

.image-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 1rem;
    align-items: center;
    transition: border-color 0.2s;
}

.image-card:hover       { border-color: #484f58; }
.image-card.converting  { border-color: #1f6feb; }
.image-card.done        { border-color: #238636; }
.image-card.error       { border-color: #da3633; }

/* --- Thumbnail --- */

.thumb-wrap {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #0d1117;
    flex-shrink: 0;
}

.thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Card body --- */

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.file-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info {
    font-size: 0.75rem;
    color: #8b949e;
    white-space: nowrap;
}

/* --- Card controls --- */

.card-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.card-controls .control-group {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.card-controls label {
    font-size: 0.75rem;
    color: #8b949e;
    min-width: fit-content;
}

.card-controls input[type="range"]  { width: 100px; }
.card-controls input[type="number"] { width: 60px; padding: 0.25rem 0.4rem; font-size: 0.8rem; }

/* --- Card actions --- */

.card-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* --- Card footer --- */

.card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 1.2rem;
}

.info-detail {
    font-size: 0.75rem;
    color: #8b949e;
}

.info-label {
    color: #6e7681;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.03em;
}

.info-original {
    color: #8b949e;
}

.info-target {
    color: #e1e4e8;
    font-weight: 600;
}

.card-footer .saved     { color: #3fb950; font-weight: 600; }
.card-footer .increased { color: #f85149; font-weight: 600; }

/* --- Progress --- */

.progress-bar {
    flex: 1;
    height: 4px;
    background: #30363d;
    border-radius: 2px;
    overflow: hidden;
    display: none;
}

.progress-bar.visible {
    display: block;
}

.progress-fill {
    height: 100%;
    background: #58a6ff;
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.status-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.format-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    background: #1c2333;
    color: #bc8cff;
    border: 1px solid #3d2e6b;
    letter-spacing: 0.04em;
}

.status-badge.pending    { background: #21262d; color: #8b949e; }
.status-badge.converting { background: #0c2d6b; color: #58a6ff; }
.status-badge.done       { background: #0f291a; color: #3fb950; }
.status-badge.error      { background: #3d1214; color: #f85149; }

/* ==========================================================================
   Misc
   ========================================================================== */

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.lock-icon {
    font-size: 0.85rem;
    cursor: pointer;
    color: #8b949e;
    user-select: none;
}

.lock-icon.locked {
    color: #58a6ff;
}

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

@media (max-width: 768px) {
    .image-card             { grid-template-columns: 60px 1fr; }
    .thumb-wrap             { width: 60px; height: 60px; }
    .card-controls          { flex-direction: column; align-items: flex-start; }
    .global-controls        { flex-direction: column; }
    .global-actions         { margin-left: 0; }
}
