:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #111827;
    --card-bg: #1e293b;
    --accent: #ca8a04;
    --accent-hover: #a16207;
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --border-soft: rgba(255, 255, 255, 0.08);
    --input-bg: #030712;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    z-index: 9999999 !important;
    height: 100vh !important;
    overflow: hidden !important;
    position: relative !important;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.controls-scroll {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px 16px;
    min-height: 0;
    pointer-events: auto !important;
}

.control-group {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-soft);
}

.control-group h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.input-row-header {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin: 10px 0 6px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 2px;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.input-grid.quad {
    grid-template-columns: repeat(4, 1fr);
}

.input-row {
    margin-bottom: 10px;
}

.input-row label {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: var(--text-dim);
}

.input-row input[type="number"],
.input-row input[type="text"] {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-soft);
    padding: 6px 10px;
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    outline: none;
    transition: 0.2s;
}

.input-row input:focus {
    border-color: var(--accent);
}

.color-row {
    display: flex;
    gap: 4px;
}

.color-row input[type="text"] {
    flex: 1;
    pointer-events: none;
    opacity: 0.7;
}

.color-row input[type="color"] {
    width: 32px;
    height: 30px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    border: none;
}

.btn.primary {
    background: var(--accent);
    color: white;
}

.btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn.secondary {
    background: #334155;
    color: white;
}

.btn.secondary:hover {
    background: #475569;
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--border-soft);
    color: white;
}

.btn.outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.full-width {
    width: 100%;
}

.stats-counter {
    background: #0f172a;
    padding: 4px 0;
    text-align: center;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 8px;
    font-weight: 700;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-soft);
}

/* Main Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #020617;
}

.workspace-header {
    padding: 12px 20px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-soft);
    position: relative !important;
    z-index: 8888888 !important;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.logo i {
    color: var(--accent);
}

.header-hint {
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.8;
    background: rgba(202, 138, 4, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(202, 138, 4, 0.2);
    font-style: italic;
    font-weight: 500;
}

/* Mobile Responsive & UX Improvements */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 100;
    background: var(--accent);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.mobile-fab-container {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 90;
    gap: 12px;
    flex-direction: column-reverse;
}

.fab {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid var(--border-soft);
}

.fab i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.fab.primary {
    background: var(--accent);
}

.fab.secondary {
    width: 45px;
    height: 45px;
    opacity: 0.8;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .mobile-toggle {
        display: flex;
    }

    .mobile-fab-container {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -360px;
        top: 0;
        bottom: 0;
        width: 320px;
        max-height: 100vh;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 99;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.8);
    }

    .sidebar.active {
        left: 0;
    }

    .preview-container {
        padding: 40px 10px;
        touch-action: pan-x pan-y pinch-zoom;
    }

    .workspace-header {
        padding-left: 70px;
    }

    .header-hint {
        font-size: 0.7rem;
    }
}

@media (max-width: 640px) {
    .header-hint {
        display: none;
    }

    .zoom-controls {
        display: none;
    }

    .logo span {
        font-size: 0.75rem;
    }

    .input-grid.quad {
        grid-template-columns: 1fr 1fr;
    }

    .preview-container {
        padding: 10px;
    }
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.zoom-controls input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
}

.preview-container {
    flex: 1;
    overflow: auto;
    padding: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
}

canvas {
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000000 !important;
}

.modal {
    background: var(--sidebar-bg);
    width: 95vw;
    height: 90vh;
    max-width: 1200px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-soft);
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title i {
    color: var(--accent);
}

.modal-toolbar {
    padding: 16px 24px;
    display: flex;
    gap: 20px;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
}

.search-box input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-soft);
    padding: 10px 16px 10px 44px;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
}

.actions {
    display: flex;
    gap: 12px;
}

.gallery-grid {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.gallery-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
    border: 1px solid transparent;
}

.gallery-item:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.07);
}

.gallery-item.selected {
    border-color: var(--accent);
    background: rgba(202, 138, 4, 0.1);
    position: relative;
    box-shadow: 0 0 15px rgba(202, 138, 4, 0.2);
}

.gallery-item.selected::after {
    content: "✓";
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--sidebar-bg);
}

.gallery-item img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.gallery-item span {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Toggle Slider */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
    user-select: none;
    margin-left: auto;
}

.user-profile-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    background: #1e293b;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: 0.2s;
}

.user-profile-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent);
}

.user-avatar-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info-mini {
    display: flex;
    flex-direction: column;
}

.user-info-mini .username {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.user-info-mini .balance {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 190px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    padding: 8px;
    z-index: 10000000 !important;
}

.dropdown-menu.show {
    display: flex !important;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #f1f5f9;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    transition: 0.2s;
}

.dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
}

.dropdown-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 6px 0;
}

.admin-panel-link {
    color: #38bdf8 !important;
}

.logout-link {
    color: #f87171 !important;
}