/* ===== Image Studio Styles ===== */
:root {
    --bg: #0a0c12;
    --bg-panel: #11131a;
    --bg-header: #161922;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #a78bfa;
    --accent-hover: #8b5cf6;
    --text: #e8eaed;
    --text-muted: #8b8fa3;
    --radius: 8px;
    --header-height: 56px;
    --sidebar-width: 72px;
    --panel-width: 280px;
}

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

html {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Allow orbs to show */
    background: #050608;
}

button {
    font-family: inherit;
    font-size: inherit;
}

.hidden {
    display: none !important;
}

/* ===== App Shell ===== */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ===== Background Orbs ===== */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    /* Reduced blur slightly for more definition */
    opacity: 0.6;
    /* Boosted opacity */
    animation: float 20s ease-in-out infinite;
    mix-blend-mode: screen;
    /* Brighter blending */
}

.orb-1 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    /* Brighter purple */
    top: -250px;
    left: -150px;
    animation-delay: 0s;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    /* Brighter blue */
    bottom: -200px;
    right: -150px;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #ec4899 0%, transparent 70%);
    /* Brighter pink */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.4;
    animation-duration: 25s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    33% {
        transform: translate(40px, -60px);
    }

    66% {
        transform: translate(-30px, 30px);
    }
}

/* ===== Top Bar ===== */
.top-bar {
    height: var(--header-height);
    background: rgba(15, 17, 23, 0.4);
    /* Much more transparent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
}

.accent {
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.4));
}

.back-home {
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s;
}

.back-home:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.icon-sm {
    width: 20px;
    height: 20px;
    display: block;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.divider-v {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

/* ===== Main Layout ===== */
.studio-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Sidebar Nav */
.sidebar-nav {
    width: var(--sidebar-width);
    background: rgba(15, 17, 23, 0.35);
    /* Translucent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 8px;
    z-index: 5;
}

.nav-item {
    width: 48px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(167, 139, 250, 0.25), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.nav-item:hover::before {
    opacity: 1;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    position: relative;
    z-index: 1;
    transition: transform 0.3s;
    filter: drop-shadow(0 0 0 rgba(167, 139, 250, 0));
}

.nav-item:hover svg {
    transform: scale(1.1);
    color: var(--text);
    filter: drop-shadow(0 0 5px rgba(167, 139, 250, 0.5));
}

.nav-item span {
    font-size: 0.65rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.nav-item.active {
    color: #fff;
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.25);
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

/* Tool Panel */
.tool-panel {
    width: var(--panel-width);
    background: rgba(12, 14, 18, 0.35);
    /* Translucent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tool-settings h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Inputs & Buttons */
.btn {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

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

.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-subtle {
    background: transparent;
    color: var(--text-muted);
}

.btn-subtle:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover:not([disabled]) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border);
    transform: scale(1.05);
}

.btn-icon.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.4);
}

.btn-icon[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-option {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-option:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-option.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

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

.grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Utilities */
.text-xs {
    font-size: 0.7rem;
}

.text-sm {
    font-size: 0.8rem;
}

.mt-1 {
    margin-top: 4px;
}

.text-accent {
    color: var(--accent);
}

/* Info Box */
.info-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.size-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

/* Format Button Layout */
.format-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.fmt-name {
    font-weight: 600;
}

.fmt-desc {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Range Slider */
input[type=range] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.5);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-wrap {
    flex: 1;
}

.input-wrap input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 6px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.input-wrap input:focus {
    border-color: var(--accent);
}

/* Specific style for Max Size Input */
#maxSizeInput {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    width: 100%;
    outline: none;
    transition: all 0.2s;
}

#maxSizeInput:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

/* Remove Arrows/Spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.presets-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 4px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.badge-btn:hover {
    border-color: var(--text);
    color: var(--text);
}

/* Workspace */
.workspace {
    flex: 1;
    background: #050608;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(#1a1d26 1px, transparent 1px);
    background-size: 20px 20px;
}

.upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 18, 0.8);
    backdrop-filter: blur(4px);
    z-index: 20;
}

.upload-box {
    text-align: center;
    border: 2px dashed var(--border);
    padding: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-box:hover {
    border-color: var(--accent);
    background: rgba(167, 139, 250, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 16px;
    opacity: 0.8;
}

.canvas-container {
    padding: 40px;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    max-height: 80vh;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    inset: 0;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    cursor: move;
}

.crop-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
}

.crop-grid::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 33.33%;
    right: 33.33%;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.crop-grid::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 33.33%;
    bottom: 33.33%;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    z-index: 10;
}

.handle-nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.handle-n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle-ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.handle-e {
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.handle-se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.handle-s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.handle-w {
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    cursor: ew-resize;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 100px;
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.zoom-controls span {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-icon-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-bottom: 20px;
}

.format-options {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 8px;
}

.format-options .btn-option {
    flex: 1;
    text-align: center;
    border: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .studio-body {
        flex-direction: column;
    }

    .sidebar-nav {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: center;
        padding: 8px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .tool-panel {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav-item {
        height: 40px;
        width: auto;
        flex-direction: row;
        padding: 0 12px;
    }
}