﻿.tool-container {
    --kimg-primary: #0ea5e9;
    --kimg-primary-dark: #0284c7;
    --kimg-bg-card: #0f172a;
    --kimg-bg-soft: #111827;
    --kimg-border: #334155;
    --kimg-text: #e2e8f0;
    --kimg-muted: #94a3b8;
    --kimg-hover: rgba(14, 165, 233, 0.14);
    --kimg-shadow: 0 10px 24px rgba(2, 6, 23, 0.3);
    --primary: var(--kimg-primary);
    --secondary: var(--kimg-primary-dark);
    --bg-card: var(--kimg-bg-card);
    --bg-primary-light: var(--kimg-hover);
    --text-main: var(--kimg-text);
    --border: var(--kimg-border);
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem 6rem;
}

body.light-mode .tool-container {
    --kimg-bg-card: #ffffff;
    --kimg-bg-soft: #f8fafc;
    --kimg-border: #dbe3ef;
    --kimg-text: #1e293b;
    --kimg-muted: #64748b;
    --kimg-hover: rgba(14, 165, 233, 0.08);
    --kimg-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

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

.tool-header-custom h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
    color: var(--kimg-text);
}

.tool-header-custom p {
    color: var(--kimg-muted);
}

.upload-zone {
    border: 2px dashed var(--kimg-border);
    border-radius: 1rem;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--kimg-bg-card);
    color: var(--kimg-text);
    transition: all 0.25s ease;
    cursor: pointer;
    margin-bottom: 2rem;
    box-shadow: var(--kimg-shadow);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--kimg-primary);
    background: var(--kimg-hover);
    transform: translateY(-2px);
}

.upload-zone h3 {
    color: var(--kimg-text);
}

.pages-flow {
    display: none;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 2rem;
    background: var(--kimg-bg-card);
    border-radius: 1rem;
    border: 1px solid var(--kimg-border);
    min-height: 200px;
    margin-bottom: 5rem;
    box-shadow: var(--kimg-shadow);
}

.page-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-card {
    width: 140px;
    height: 198px;
    background: var(--kimg-bg-soft);
    border: 1px solid var(--kimg-border);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}

.page-card:hover {
    transform: translateY(-3px);
    border-color: var(--kimg-primary);
}

.page-preview-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.page-num {
    position: absolute;
    bottom: 0.5rem;
    background: rgba(2, 6, 23, 0.78);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    pointer-events: none;
}

.image-card {
    width: 140px;
    height: 198px;
    background: var(--kimg-bg-soft);
    border: 2px solid var(--kimg-primary);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.delete-img-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.delete-img-btn:hover {
    transform: scale(1.1);
    background: #dc2626;
}

.insert-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--kimg-bg-soft);
    border: 2px dashed var(--kimg-primary);
    color: var(--kimg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.insert-btn:hover {
    background: var(--kimg-primary);
    color: #fff;
    transform: scale(1.08);
}

.insert-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.5rem;
    background: rgba(2, 6, 23, 0.86);
    color: #fff;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 5px;
}

.insert-btn:hover::before {
    opacity: 1;
}

.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--kimg-bg-card);
    border-top: 1px solid var(--kimg-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -12px 24px rgba(2, 6, 23, 0.35);
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-bar.visible {
    transform: translateY(0);
}

.download-btn {
    background: linear-gradient(135deg, var(--kimg-primary) 0%, var(--kimg-primary-dark) 100%);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.download-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.download-btn:disabled {
    filter: grayscale(1);
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 780px) {
    .action-bar {
        padding: 12px 16px;
        gap: 10px;
        flex-direction: column;
        align-items: flex-start;
    }

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