@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #F3DDC3;
    --bg-secondary: #E8D0B3;
    --bg-tertiary: #DCC4A8;
    --accent-primary: #232121;
    --accent-secondary: #3a3635;
    --accent-gradient: linear-gradient(135deg, #232121 0%, #3a3635 100%);
    --text-primary: #232121;
    --text-secondary: #4a4442;
    --text-tertiary: #6b6360;
    --border-color: #c9b89a;
    --range-bg: #b8a38a;
    --success: #10b981;
    --shadow-sm: 0 2px 8px rgba(26, 26, 26, 0.4);
    --shadow-md: 0 4px 16px rgba(26, 26, 26, 0.4);
    --shadow-lg: 0 8px 32px rgba(26, 26, 26, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xlg: 24px;
    --lock-color: #6D6358;
}

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

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.drop-zone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xlg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-zone:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.drop-zone:hover::before {
    opacity: 0.05;
}

.drop-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: scale(1.02);
}

.drop-zone.dragover::before {
    opacity: 0.1;
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--accent-primary);
    stroke-width: 1.5;
}

.drop-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.drop-subtext {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.drop-formats {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* Controls Section */
.controls-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xlg);
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Fix for narrow mobile screens (375-391px) */
@media (min-width: 375px) and (max-width: 391px) {
    .controls-grid {
        gap: 1rem;
        grid-template-columns: 1fr;
    }

    .control-group {
        width: 100%;
        min-width: 0;
    }

    .control-group>* {
        max-width: 100%;
        min-width: 0;
    }

    .mode-toggle,
    .info-text {
        width: 100%;
    }

    .resize-controls {
        gap: 0.375rem;
    }

    .resize-controls input {
        min-width: 0;
        font-size: 1rem;
        padding: 0.5rem 0.625rem;
    }

    .lock-btn {
        padding: 0.5rem;
        min-width: 42px;
    }

    .apply-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}


.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mode-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(26, 26, 26, 0.1);
}

.mode-btn.active {
    background: var(--accent-gradient);
    color: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.4);
}

/* Reset All Button */
.reset-all-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-all-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

/* Reset Section */
.reset-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Sliders */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--range-bg);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.4);
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.4);
    transition: transform 0.2s ease;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Range Control Container */
.range-control-container {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.range-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.range-manual-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    transition: all 0.2s ease;
}

.range-manual-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.4);
}

/* Pixelization Row */
.pixelization-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.info-text {
    padding: 0.8595rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-size: 0.9375rem;
    font-family: 'Monaco', 'Courier New', monospace;
    opacity: 0.6;
}

/* Preview Header */
.preview-header {
    margin-bottom: 1.5rem;
}

.preview-header .preview-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.preview-header .control-group {
    margin-bottom: 0;
}

/* Download Buttons Wrapper - For horizontal centering only */
.download-buttons-wrapper {
    display: flex;
    justify-content: center;
    position: fixed;
    bottom: 1rem;
    left: 0;
    right: 0;
    z-index: 100;
    pointer-events: none;
    /* Allow clicks to pass through wrapper */
}

.download-buttons-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    width: fit-content;
    padding: 1rem;
    background: rgba(243, 221, 195, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-xlg);
    pointer-events: auto;
    /* Re-enable clicks on buttons */
}

.download-btn-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(26, 26, 26, 0.4);
    white-space: nowrap;
}

.download-btn-main:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(26, 26, 26, 0.4);
}

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

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

.download-btn-main svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Mobile text switching */
.btn-text-mobile {
    display: none;
}

.btn-text-full {
    display: inline;
}

@media (max-width: 640px) {
    .btn-text-mobile {
        display: inline;
    }

    .btn-text-full {
        display: none;
    }

    .download-btn-main {
        padding: 0.875rem 1.25rem;
    }
}


/* Resize Controls */
.resize-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.resize-controls input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    height: 42px;
}

.resize-controls input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.4);
}

.resize-controls input::placeholder {
    color: var(--text-tertiary);
}

.resize-controls input[type="number"] {
    width: 80px;
    height: 52px;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    box-sizing: border-box;
}

.resize-controls button {
    height: 52px;
}

.lock-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--lock-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.lock-btn svg {
    width: 24px;
    height: 24px;
}

.lock-btn.active {
    background: var(--lock-color);
    border-color: var(--lock-color);
    color: var(--bg-primary);
}

.apply-btn {
    height: 52px;
    padding: 0.5rem 1.5rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--bg-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    white-space: nowrap;
}

.apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.4);
}

.apply-btn:active {
    transform: translateY(0);
}

.original-size {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    font-family: 'Monaco', 'Courier New', monospace;
}

.original-size span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Crop Buttons */
.crop-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.crop-btn {
    padding: 0.75rem 1rem;
    background: var(--accent-primary);
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    color: var(--bg-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.crop-btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.crop-btn:hover {
    background: var(--bg-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.crop-btn:active {
    transform: translateY(0);
}

.controls-grid:last-of-type {
    margin-bottom: 0;
}

/* Preview Section */
.preview-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xlg);
    padding: 2rem;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.preview-area {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.preview-area svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.processing-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.processing-indicator p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
/* Tablet and small desktop - single column controls */
@media (max-width: 907px) {
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Mobile devices */
@media (max-width: 768px) {

    .controls-section,
    .preview-section {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    .preview-area {
        min-height: auto;
    }

    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

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

    .drop-zone {
        padding: 3rem 1.5rem;
    }

    /* Resize controls - wrap on small screens */
    .resize-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .resize-controls input[type="number"] {
        flex: 1 1 auto;
        min-width: 70px;
    }

    .lock-btn {
        width: 52px;
        flex-shrink: 0;
    }

    .apply-btn {
        flex: 1 1 100%;
        width: 100%;
    }

    /* Crop buttons - 2 columns on mobile for better touch targets */
    .crop-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .crop-btn:last-child {
        grid-column: 1 / -1;
    }

    /* Circle settings - stack vertically for better slider usability */
    .pixelization-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Adjust font sizes for mobile */
    .control-label {
        font-size: 0.9375rem;
    }

    .range-manual-input {
        font-size: 1rem;
    }
}

/* Extra small devices (phones in portrait, less than 375px) */
@media (max-width: 374px) {

    .controls-section,
    .preview-section {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    .preview-area {
        min-height: auto;
    }

    .container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    /* Make resize inputs full width on very small screens */
    .resize-controls input[type="number"] {
        flex: 1 1 100%;
        width: 100%;
    }

    .lock-btn {
        width: 100%;
    }

    /* Single column for crop buttons on very small screens */
    .crop-buttons {
        grid-template-columns: 1fr;
    }

    .crop-btn:last-child {
        grid-column: 1;
    }
}

/* Hover effects for devices with hover capability (not touch screens) */
@media (hover: hover) {
    .lock-btn:hover {
        background: var(--lock-color);
        border-color: var(--lock-color);
        color: var(--bg-primary);
        transform: scale(1.05);
    }
}

/* Smooth Animations */
@media (prefers-reduced-motion: no-preference) {
    * {
        transition-duration: 0.2s;
    }
}