/* Custom styles for AI Image Generator */

/* Scrollbar styling - Dark mode */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Select option styling */
select option {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

/* Custom border width */
.border-3 {
    border-width: 3px;
}

/* Toast animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-enter {
    animation: slideIn 0.3s ease-out forwards;
}

.toast-exit {
    animation: slideOut 0.3s ease-in forwards;
}

/* Drag over state for upload zone */
#upload-zone.drag-over {
    border-color: var(--color-accent);
    background: var(--color-accent-muted);
    transform: scale(1.02);
}

/* Generated image drag cursor */
#generated-image {
    cursor: grab;
}

#generated-image:active {
    cursor: grabbing;
}

/* History thumbnail drag */
.history-thumb img {
    cursor: grab;
}

.history-thumb img:active {
    cursor: grabbing;
}

/* Focus ring */
textarea:focus,
input:focus,
select:focus {
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.2);
}

/* Button press effect */
button:active:not(:disabled) {
    transform: scale(0.98);
}

/* Range input styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #b8860b;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

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

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

/* Loading spinner */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* History thumbnail hover */
.history-thumb {
    transition: all 0.2s ease;
}

.history-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Canvas cursor for edit mode */
#edit-canvas.drawing {
    cursor: crosshair;
}

/* Canvas container - adjust based on content */
#canvas-container {
    min-height: 200px;
    border: 1px solid var(--color-border);
}

/* When image is displayed, remove extra space */
#canvas-container.has-image {
    background: transparent;
    border: none;
    flex: 0 1 auto;
    min-height: auto;
}

#canvas-container.has-image #generated-image {
    max-height: calc(100vh - 180px);
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Section layout when showing image */
#canvas-section.showing-image {
    justify-content: flex-start;
    overflow-y: auto;
}

@media (max-width: 767px) {
    #canvas-container.has-image #generated-image {
        max-height: calc(55vh - 60px);
    }
}

/* Modal backdrop blur */
#settings-modal {
    backdrop-filter: blur(4px);
}

/* Pulse animation for loading */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Size button active state */
.size-btn.active,
.mobile-size-btn.active {
    border-color: #b8860b;
    color: #b8860b;
}

/* ===== Mobile Responsive Styles ===== */

/* Safe area handling for iOS */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    #mobile-panel {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Mobile bottom panel styles */
#mobile-panel {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Touch-friendly tap targets */
@media (max-width: 767px) {
    button,
    select,
    .size-btn,
    .mobile-size-btn {
        min-height: 44px;
    }

    /* Improve touch scrolling */
    #history-grid {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Prevent text selection on buttons */
    button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Adjust canvas container for mobile */
    #canvas-container {
        min-height: 200px;
    }

    /* Mobile toast positioning */
    #toast-container {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: calc(45vh + 1rem);
    }

    #toast-container > div {
        max-width: 100%;
    }

    /* Mobile modal adjustments */
    #settings-modal > div {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    /* History thumbnails on mobile */
    .history-thumb {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
    }

    /* Disable hover effects on touch */
    .history-thumb:hover {
        transform: none;
        box-shadow: none;
    }

    .history-thumb:active {
        transform: scale(0.95);
    }
}

/* Small phone screens */
@media (max-width: 375px) {
    .mobile-size-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    #mobile-panel {
        padding: 0.5rem;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #canvas-container {
        min-height: 120px;
    }

    #empty-state h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    #empty-state p {
        display: none;
    }

    #empty-state > div:first-child {
        width: 2.5rem;
        height: 2.5rem;
        margin-bottom: 0.5rem;
    }

    #mobile-panel {
        max-height: 50vh;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
    #sidebar {
        width: 320px;
    }
}

/* High contrast focus for accessibility */
@media (prefers-contrast: high) {
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #b8860b;
        outline-offset: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
