/* ===== CSS VARIABLES (Light/Dark) ===== */
:root {
    /* Dark Mode (Default) */
    --bg-primary: #0b0d10;
    --bg-secondary: #13161b;
    --bg-card: #14181e;
    --bg-input: #1a1f26;
    --bg-panel: #0f1218;
    --border-color: #222831;
    --border-light: #2a2f38;
    --text-primary: #f0f2f5;
    --text-secondary: #9aa3b3;
    --text-muted: #5a6577;
    --shadow-color: rgba(0, 0, 0, 0.6);
    --hover-bg: #3d444f;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --modal-bg: #14181e;
    --input-bg: #1a1f26;
}

[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f5f7fa;
    --bg-panel: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #dce1e8;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --hover-bg: #edf2f7;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --modal-bg: #ffffff;
    --input-bg: #f7fafc;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 20px;
    min-height: 100vh;
}

/* ===== WELCOME OVERLAY ===== */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: welcomeFadeOut 0.8s ease 2.5s forwards;
}

.welcome-content {
    text-align: center;
    animation: welcomePulse 1.5s ease-in-out infinite;
}

.welcome-icon {
    font-size: 5rem;
    color: #f7b731;
    margin-bottom: 20px;
    animation: welcomeBounce 1.2s ease-in-out infinite;
}

.welcome-title {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f7b731, #f5a623);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    letter-spacing: 2px;
    margin-bottom: 30px;
}

.welcome-loader {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.welcome-loader span {
    width: 12px;
    height: 12px;
    background: #f7b731;
    border-radius: 50%;
    animation: welcomeDot 1.2s ease-in-out infinite;
}

.welcome-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.welcome-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes welcomeBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes welcomePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes welcomeDot {
    0%, 100% { transform: scale(0.6); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
}

@keyframes welcomeFadeOut {
    0% { opacity: 1; visibility: visible; }
    100% { opacity: 0; visibility: hidden; }
}

/* ===== HEADER ===== */
.header {
    background: var(--bg-secondary);
    border-radius: 28px;
    padding: 24px 35px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-content h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-content h1 i {
    color: #f7b731;
    margin-right: 10px;
}

.header-content h1 span {
    background: linear-gradient(135deg, #f7b731, #f5a623);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.header-content p {
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-theme {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-theme:hover {
    background: var(--hover-bg);
    transform: rotate(20deg);
}

.btn-manage {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-manage:hover {
    background: var(--hover-bg);
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(247, 183, 49, 0.15);
}

/* ===== FILTERS ===== */
.filters-section {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 18px 22px;
    margin-bottom: 35px;
    border: 1px solid var(--border-color);
}

.filters-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: 14px;
    padding: 4px 14px;
    border: 1px solid var(--border-light);
    transition: 0.2s;
    gap: 8px;
    flex: 1 1 180px;
}

.filter-group:focus-within {
    border-color: #f7b731;
    box-shadow: 0 0 0 3px rgba(247, 183, 49, 0.1);
}

.filter-group i {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.filter-group input[type="text"],
.filter-group input[type="number"] {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 4px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    width: 100%;
    outline: none;
}

.filter-group input[type="text"]::placeholder,
.filter-group input[type="number"]::placeholder {
    color: var(--text-muted);
}

.filter-group input[type="number"] {
    width: 70px;
    -moz-appearance: textfield;
}

.filter-group input[type="number"]::-webkit-outer-spin-button,
.filter-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.filter-group span {
    color: var(--text-muted);
}

.color-filter {
    flex: 0 1 auto;
    padding: 4px 12px;
}

.color-filter input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-filter input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-filter input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-light);
    border-radius: 8px;
}

#colorFilterLabel {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 40px;
}

.clear-filter {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: 0.2s;
}

.clear-filter:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.btn-clear-filters {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-clear-filters:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* ===== PRODUCTS SECTION ===== */
.products-section {
    max-width: 1400px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.section-header h2 i {
    color: #f7b731;
    margin-right: 12px;
}

.badge {
    background: var(--bg-input);
    padding: 6px 16px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

/* ===== PRODUCTS GRID ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 28px;
}

/* ===== PRODUCT CARD ===== */
.product-card {
    background: var(--bg-card);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    box-shadow: 0 10px 20px var(--card-shadow);
}

.product-card:hover {
    transform: translateY(-8px);
    border-color: #f7b731;
    box-shadow: 0 20px 40px rgba(247, 183, 49, 0.08);
}

.card-image {
    height: 200px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: 700;
    position: relative;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.card-image .initial {
    font-size: 4.5rem;
    font-weight: 700;
    opacity: 0.9;
}

.card-body {
    padding: 20px 20px 22px;
}

.card-body h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-body .price-tag {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f7b731;
    margin: 6px 0;
}

.card-body .price-tag.free {
    color: #00d2ff;
}

.card-body .color-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    margin-right: 6px;
    vertical-align: middle;
}

.card-body .short-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
    display: none;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--modal-bg);
    margin: 5% auto;
    max-width: 700px;
    width: 92%;
    border-radius: 32px;
    border: 1px solid var(--border-color);
    box-shadow: 0 40px 80px var(--shadow-color);
    animation: slideUp 0.35s ease;
    position: relative;
    overflow: hidden;
}

.close-modal {
    position: absolute;
    top: 18px;
    right: 24px;
    font-size: 2.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    z-index: 10;
    background: var(--bg-input);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.modal-image {
    width: 100%;
    height: 300px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    color: var(--text-muted);
    overflow: hidden;
    position: relative;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.modal-image .image-placeholder {
    font-size: 4rem;
    color: var(--text-muted);
}

.modal-info {
    padding: 30px 34px 34px;
}

.modal-info h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-info #modalDesc {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 16px;
}

.modal-price {
    font-size: 2rem;
    font-weight: 700;
    color: #f7b731;
    margin-bottom: 24px;
}

.modal-price.free {
    color: #00d2ff;
}

.btn-buy {
    background: linear-gradient(135deg, #f7b731, #f5a623);
    border: none;
    color: #0b0d10;
    padding: 16px 32px;
    border-radius: 60px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.3s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-buy:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(247, 183, 49, 0.3);
}

.btn-buy.free-btn {
    background: linear-gradient(135deg, #00d2ff, #0090c7);
}

.btn-buy.free-btn:hover {
    box-shadow: 0 10px 30px rgba(0, 210, 255, 0.3);
}

/* ===== MANAGE PANEL ===== */
.manage-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    height: 100%;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    padding: 30px 28px;
    transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2000;
    overflow-y: auto;
    box-shadow: -20px 0 60px var(--shadow-color);
}

.manage-panel.open {
    right: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.panel-header h2 {
    font-size: 1.6rem;
}

.btn-close-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-close-panel:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.manage-form .form-group {
    margin-bottom: 16px;
}

.manage-form label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.manage-form label i {
    margin-right: 6px;
    color: #f7b731;
}

.manage-form input {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: 0.2s;
}

.manage-form input:focus {
    border-color: #f7b731;
    outline: none;
    box-shadow: 0 0 0 3px rgba(247, 183, 49, 0.1);
}

.manage-form small {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 6px 16px;
}

.color-picker-wrapper input[type="color"] {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-light);
    border-radius: 12px;
}

#colorHexDisplay {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-family: monospace;
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #f7b731, #f5a623);
    border: none;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #0b0d10;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 8px;
}

.btn-submit:hover {
    transform: scale(0.98);
    box-shadow: 0 8px 25px rgba(247, 183, 49, 0.25);
}

.manage-list {
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--input-bg);
    padding: 12px 16px;
    border-radius: 14px;
    margin-bottom: 10px;
}

.manage-item .item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.manage-item .item-color {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.manage-item .item-name {
    font-weight: 600;
}

.manage-item .delete-mini {
    background: transparent;
    border: none;
    color: #e74c3c;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: 0.2s;
}

.manage-item .delete-mini:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===== IMAGE EDITOR BUTTONS ===== */
.btn-preview:hover {
    background: var(--hover-bg);
}

.btn-editor {
    transition: 0.2s;
}

.btn-editor:hover {
    background: var(--hover-bg);
    transform: scale(0.97);
}

#imagePreviewContainer {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cropper.js custom styles */
.cropper-view-box {
    border-radius: 12px;
    box-shadow: 0 0 0 2px #f7b731;
}

.cropper-face {
    background-color: rgba(0, 0, 0, 0.3);
}

.cropper-line {
    background-color: #f7b731;
}

.cropper-point {
    background-color: #f7b731;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .filters-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        flex: 1 1 auto;
    }

    .filter-group input[type="text"],
    .filter-group input[type="number"] {
        width: 100%;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header-content h1 {
        font-size: 1.6rem;
    }

    .manage-panel {
        width: 100%;
        right: -100%;
    }

    .modal-content {
        margin: 10% auto;
        width: 96%;
    }

    .modal-image {
        height: 200px;
    }

    .products-grid {
        grid-template-columns: 1fr 1fr;
    }

    .color-filter {
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 18px 20px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .welcome-title {
        font-size: 2.5rem;
    }
}