/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --success-hover: #059669;
    --accent-color: #f59e0b;
    --accent-hover: #d97706;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-2: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--gradient-1);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Workspace */
.workspace {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

#artworkCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.canvas-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
    pointer-events: none;
    text-align: center;
}

.canvas-overlay.hidden {
    display: none;
}

/* Controls Panel */
.controls-panel {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select */
select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

select:hover, select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    text-align: right;
}

/* Color Palette */
.color-palette {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.palette-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.palette-option:hover {
    background: var(--bg-primary);
}

.palette-option.active {
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.color-swatch {
    width: 32px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.custom-swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    font-size: 0.9rem;
}

.palette-option span:last-child {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Custom Colors */
.custom-color-inputs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.custom-color {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.custom-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.custom-color::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

/* Background Color Picker */
.bg-color-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#bgColorPicker {
    width: 50px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}

#bgColorPicker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#bgColorPicker::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

.color-hex {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn svg {
    flex-shrink: 0;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover {
    background: var(--secondary-hover);
}

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

.btn-success:hover {
    background: var(--success-hover);
}

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

.btn-accent:hover {
    background: var(--accent-hover);
}

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

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Gallery Section */
.gallery-section {
    margin-top: 2rem;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.gallery-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

.gallery-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    color: var(--text-secondary);
    text-align: center;
}

.gallery-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.gallery-empty.hidden {
    display: none;
}

.gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.gallery-item:hover {
    transform: scale(1.05);
    z-index: 10;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 1rem 0.75rem 0.75rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--danger-color);
}

#modalImage {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gallery-item {
    animation: fadeIn 0.3s ease;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        order: 2;
    }

    .canvas-container {
        order: 1;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 1rem;
    }

    .color-palette {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .button-group .btn:first-child {
        grid-column: 1 / -1;
    }

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

    .gallery-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .controls-panel {
        padding: 1rem;
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .custom-color-inputs {
        justify-content: space-between;
    }

    .custom-color {
        width: 35px;
        height: 35px;
    }

    .modal-actions {
        flex-direction: column;
        width: 100%;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 40px var(--shadow-color);
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid var(--success-color);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-left-color: var(--danger-color);
}
