/* Image Studio Pro - 통합 스타일 */

/* ==================== Base & Reset ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp6, 32px) var(--sp4, 16px);
}

.is-container h1 {
    text-align: center;
    font-size: var(--fs-h1, 2.5rem);
    font-weight: 700;
    color: var(--g900, #18181b);
    margin-bottom: var(--sp6, 32px);
}

section h2 {
    font-size: var(--fs-h2, 1.4rem);
    font-weight: 600;
    color: var(--g900, #18181b);
    margin-bottom: var(--sp4, 16px);
}

/* ==================== Tab Navigation ==================== */
.tabs-nav {
    display: flex;
    gap: var(--sp2, 8px);
    margin-bottom: var(--sp5, 24px);
    border-bottom: 2px solid var(--g200, #e5e7eb);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--sp2, 8px);
    padding: var(--sp3, 12px) var(--sp4, 16px);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--g500, #6b7280);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--brand, #6366f1);
    background: var(--g100, #f3f4f6);
}

.tab-btn.active {
    color: var(--brand, #6366f1);
    border-bottom-color: var(--brand, #6366f1);
}

.tab-btn .material-icons {
    font-size: 1.3rem;
}

/* ==================== Tab Content ==================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== Cards ==================== */
.card {
    background: var(--glass-bg, rgba(255,255,255,0.7));
    backdrop-filter: blur(var(--blur, 20px));
    border-radius: var(--radius-card, 1.2rem);
    padding: var(--sp5, 24px);
    margin-bottom: var(--sp5, 24px);
    box-shadow: var(--shadow, 0 4px 32px rgba(0,0,0,0.06));
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover, 0 8px 40px rgba(0,0,0,0.12));
}

.card h2 {
    font-size: var(--fs-h2, 1.8rem);
    font-weight: 700;
    color: var(--g900, #18181b);
    margin-bottom: var(--sp4, 16px);
}

.card h3 {
    font-size: var(--fs-h3, 1.2rem);
    font-weight: 600;
    color: var(--g900, #18181b);
    margin-top: var(--sp4, 16px);
    margin-bottom: var(--sp3, 12px);
}

/* ==================== Upload Area ==================== */
.upload-area {
    border: 2px dashed var(--g300, #d4d4d8);
    border-radius: var(--radius-btn, 8px);
    padding: var(--sp7, 48px) var(--sp5, 24px);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--g100, #f3f4f6);
    margin-bottom: var(--sp4, 16px);
}

.upload-area:hover {
    border-color: var(--brand, #6366f1);
    background: var(--g200, #e5e7eb);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp3, 12px);
}

.upload-content i {
    font-size: 3rem;
    color: var(--g500, #6b7280);
}

.upload-content p {
    color: var(--g600, #52525b);
    margin: 0;
}

.upload-content .help-text {
    font-size: 0.875rem;
    color: var(--g500, #6b7280);
    margin-top: var(--sp2, 8px);
}

/* ==================== Canvas ==================== */
canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-btn, 8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    display: block;
    margin: var(--sp4, 16px) auto;
    background: var(--g100, #f3f4f6);
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp4, 16px);
    margin: var(--sp5, 24px) 0;
}

.stat-card {
    background: var(--g100, #f3f4f6);
    padding: var(--sp4, 16px);
    border-radius: var(--radius-btn, 8px);
    text-align: center;
}

.stat-label {
    color: var(--g500, #6b7280);
    font-size: 0.9rem;
    margin-bottom: var(--sp2, 8px);
}

.stat-value {
    color: var(--brand, #6366f1);
    font-size: 1.8rem;
    font-weight: 700;
}

/* ==================== Image Grid ==================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--sp3, 12px);
    margin: var(--sp4, 16px) 0;
}

.image-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-btn, 8px);
    border: 2px solid var(--g200, #e5e7eb);
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-grid img:hover {
    border-color: var(--brand, #6366f1);
    transform: scale(1.05);
}

.image-grid img.active {
    border-color: var(--brand, #6366f1);
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.image-item {
    position: relative;
}

.image-item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-item:hover .image-item-remove {
    opacity: 1;
}

/* ==================== PDF Image Grid (Draggable) ==================== */
.pdf-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--sp3, 12px);
    margin: var(--sp4, 16px) 0;
}

.pdf-image-item {
    position: relative;
    cursor: move;
    border-radius: var(--radius-btn, 8px);
    overflow: hidden;
    background: var(--g100, #f3f4f6);
    transition: all 0.2s ease;
}

.pdf-image-item.dragging {
    opacity: 0.5;
}

.pdf-image-item.drag-over {
    border: 2px dashed var(--brand, #6366f1);
    transform: scale(1.05);
}

.pdf-image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.pdf-image-order {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: var(--brand, #6366f1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pdf-image-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--sp2, 8px);
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-image-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-weight: bold;
}

.pdf-image-item:hover .pdf-image-remove {
    opacity: 1;
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: var(--sp4, 16px);
}

.form-group label {
    display: block;
    margin-bottom: var(--sp2, 8px);
    color: var(--g700, #374151);
    font-weight: 600;
    font-size: 0.95rem;
}

.select,
.input {
    width: 100%;
    padding: var(--sp3, 12px) var(--sp4, 16px);
    border: 2px solid var(--g200, #e5e7eb);
    border-radius: var(--radius-btn, 8px);
    font-family: Pretendard, system-ui, sans-serif;
    font-size: 1rem;
    color: var(--g900, #18181b);
    background: var(--g50, white);
    transition: all 0.2s ease;
}

.select:focus,
.input:focus {
    outline: none;
    border-color: var(--brand, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ==================== Slider ==================== */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: var(--g200, #e5e7eb);
    outline: none;
    -webkit-appearance: none;
    margin: var(--sp3, 12px) 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand, #6366f1);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand, #6366f1);
    cursor: pointer;
    border: none;
}

.slider-value {
    text-align: right;
    margin-top: var(--sp2, 8px);
    color: var(--g700, #374151);
    font-weight: 600;
}

/* ==================== Buttons ==================== */
.btn {
    padding: var(--sp3, 12px) var(--sp4, 16px);
    border: none;
    border-radius: var(--radius-btn, 8px);
    font-family: Pretendard, system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--sp2, 8px);
}

.btn-primary {
    background: var(--brand, #6366f1);
    color: white;
}

.btn-primary:hover {
    background: var(--brand-hov, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--g200, #e5e7eb);
    color: var(--g700, #374151);
}

.btn-secondary:hover {
    background: var(--g300, #d4d4d8);
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp3, 12px);
    margin-top: var(--sp4, 16px);
}

.btn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--sp3, 12px);
}

/* ==================== Grid Layouts ==================== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--sp4, 16px);
}

/* ==================== Toggle Switch ==================== */
.toggle {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 27px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--g300, #d4d4d8);
    transition: 0.3s;
    border-radius: 34px;
}

.toggle-thumb {
    position: absolute;
    height: 19px;
    width: 19px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-track {
    background-color: var(--brand, #6366f1);
}

.toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(24px);
}

/* ==================== Crop Controls ==================== */
.crop-controls {
    display: grid;
    gap: var(--sp3, 12px);
    margin-bottom: var(--sp3, 12px);
}

.crop-input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp3, 12px);
}

.crop-input-group label {
    display: flex;
    align-items: center;
    gap: var(--sp2, 8px);
    font-size: 0.9rem;
}

.input-sm {
    width: 80px;
    padding: var(--sp2, 8px);
    border: 2px solid var(--g200, #e5e7eb);
    border-radius: var(--radius-btn, 8px);
    font-size: 0.875rem;
}

/* ==================== Compress Result List ==================== */
.compress-result-list {
    display: grid;
    gap: var(--sp3, 12px);
}

.compress-result-item {
    display: flex;
    align-items: center;
    gap: var(--sp3, 12px);
    padding: var(--sp4, 16px);
    background: var(--g100, #f3f4f6);
    border-radius: var(--radius-btn, 8px);
    transition: all 0.2s ease;
}

.compress-result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.compress-result-preview {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-btn, 8px);
    object-fit: cover;
}

.compress-result-info {
    flex: 1;
}

.compress-result-info h4 {
    margin: 0 0 var(--sp2, 8px) 0;
    font-size: 1rem;
    color: var(--g900, #18181b);
}

.compress-result-stats {
    display: flex;
    gap: var(--sp4, 16px);
    font-size: 0.875rem;
    color: var(--g600, #52525b);
}

.compress-result-actions {
    display: flex;
    gap: var(--sp2, 8px);
}

/* ==================== Utility Classes ==================== */
.flex {
    display: flex;
}

.items-c {
    align-items: center;
}

.justify-b {
    justify-content: space-between;
}

.mt-4 {
    margin-top: var(--sp5, 24px);
}

.mb-3 {
    margin-bottom: var(--sp4, 16px);
}

/* ==================== PDF Section ==================== */
.pdf-section {
    margin-bottom: var(--sp6, 32px);
}

.pdf-section h3 {
    display: flex;
    align-items: center;
    gap: var(--sp2, 8px);
    margin-bottom: var(--sp4, 16px);
    color: var(--g900, #18181b);
}

.pdf-section h4 {
    margin: var(--sp4, 16px) 0;
    font-size: 1.1rem;
    color: var(--g800, #27272a);
}

/* ==================== Dark Theme ==================== */
[data-theme="dark"] .card {
    background: var(--glass-bg-dark, rgba(24,24,27,0.6));
}

[data-theme="dark"] .upload-area {
    background: var(--g200, #3f3f46);
    border-color: var(--g300, #52525b);
}

[data-theme="dark"] .select,
[data-theme="dark"] .input {
    background: var(--g200, #3f3f46);
    border-color: var(--g300, #52525b);
    color: var(--g900, #fafafa);
}

[data-theme="dark"] .stat-card {
    background: var(--g200, #3f3f46);
}

[data-theme="dark"] .image-grid img {
    border-color: var(--g300, #52525b);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .tabs-nav {
        flex-wrap: wrap;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .btn-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .btn-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
