/* ===== RESET & VARIABLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --success-gradient: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    --error-gradient: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    --dark-bg: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.15);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.4);
}

/* ===== BASE STYLES ===== */
body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%,
            rgba(120, 119, 198, 0.3) 0%,
            transparent 50%),
        radial-gradient(circle at 80% 20%,
            rgba(255, 119, 198, 0.3) 0%,
            transparent 50%),
        radial-gradient(circle at 40% 80%,
            rgba(120, 219, 255, 0.2) 0%,
            transparent 50%);
    z-index: -1;
    animation: backgroundShift 20s ease-in-out infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes backgroundShift {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes snip {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-15deg);
    }

    75% {
        transform: rotate(15deg);
    }
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes successPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== PARTICLES ===== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 15s linear infinite;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    position: relative;
}

.scissors-icon {
    display: inline-block;
    margin-left: 1rem;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    animation: snip 3s ease-in-out infinite;
    transform-origin: center;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 1rem;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
    font-size: 0.9rem;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== CARDS ===== */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* ===== UPLOAD AREAS ===== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.upload-area:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.02);
}

.upload-area.dragover {
    border-color: #4facfe;
    background: rgba(79, 172, 254, 0.1);
    transform: scale(1.02);
}

.upload-area.has-file {
    border-color: #56ab2f;
    background: rgba(86, 171, 47, 0.1);
}

.upload-area.error {
    border-color: #ff416c;
    background: rgba(255, 65, 108, 0.1);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.upload-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ===== FILE STATUS ===== */
.file-status {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.file-status.show {
    display: flex;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.file-preview {
    max-width: 150px;
    max-height: 100px;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.json-info {
    background: rgba(79, 172, 254, 0.1);
    border: 1px solid rgba(79, 172, 254, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.9rem;
    text-align: left;
    width: 100%;
}

.json-info h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.json-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.json-detail:last-child {
    margin-bottom: 0;
}

.error-message {
    background: rgba(255, 65, 108, 0.1);
    border: 1px solid rgba(255, 65, 108, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* ===== SPRITE PREVIEW ===== */
.sprite-preview {
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
}

.sprite-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
}

.sprite-item {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sprite-item:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: var(--shadow);
}

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

.sprite-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ===== BUTTONS ===== */
.buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn {
    flex: 1;
    padding: 1rem 2rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary {
    background: var(--secondary-gradient);
    color: white;
}

.btn-clear {
    background: var(--error-gradient);
    color: white;
    flex: 0 0 auto;
    min-width: 120px;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-loading {
    pointer-events: none;
}

.btn-loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    animation: shimmer 2s infinite;
}

.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

.btn-loading .loading-spinner {
    display: inline-block;
}

/* ===== PROGRESS ===== */
.progress-container {
    margin-top: 1rem;
    position: relative;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    display: none;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s ease;
}

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

.progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: center;
}

.cancel-btn {
    position: absolute;
    top: -2.5rem;
    right: 0;
    background: rgba(255, 65, 108, 0.2);
    border: 1px solid rgba(255, 65, 108, 0.3);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.processing .cancel-btn {
    display: flex;
}

/* ===== TOOLTIPS ===== */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ===== KEYBOARD SHORTCUTS ===== */
.keyboard-shortcuts {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1rem;
}

.shortcut {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.2rem;
    margin: 0 0.2rem;
    font-family: monospace;
}

/* ===== VERSION INFO ===== */
.version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1rem;
    padding: 0.5rem;
    opacity: 0.7;
    font-family: monospace;
}

/* ===== UTILITY CLASSES ===== */
.success-animation {
    animation: successPulse 0.6s ease-in-out;
}

.processing {
    pointer-events: none;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

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

    .buttons {
        flex-direction: column;
    }

    .upload-area {
        padding: 1.5rem;
        min-height: 150px;
    }

    .stats-bar {
        gap: 1rem;
    }

    .sprite-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}