/* Retro Avatar Cropper Styles - DOHMBOY64 Theme */

.retro-button-small {
    background: #1a1a1a;
    color: #fbbf24;
    padding: 0.5rem 1rem;
    border: 2px solid #f97316;
    box-shadow:
        inset 0 0 10px #f97316,
        2px 2px 0 #000;
    transition: all 0.2s;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    min-width: 60px;
    text-align: center;
    display: inline-block;
    text-decoration: none;
    position: relative;
    text-shadow: 0 0 5px #f97316;
    cursor: pointer;
}

.retro-button-small:hover {
    transform: translate(-1px, -1px);
    box-shadow:
        inset 0 0 15px #f97316,
        3px 3px 0 #000;
    text-decoration: none;
    color: #fbbf24;
    border-color: #fb8c00;
}

.retro-button-small:active,
.retro-button-small.toggled {
    transform: translate(1px, 1px);
    box-shadow:
        inset 0 0 20px #f97316,
        1px 1px 0 #000;
    background: #2a2a2a;
    border-color: #fb8c00;
}

.retro-button-small.toggled {
    background: #f97316;
    color: #000;
    text-shadow: none;
}

/* Retro Button Tiny */
.retro-button-tiny {
    background: #1a1a1a;
    color: #fbbf24;
    padding: 0.25rem 0.5rem;
    border: 2px solid #f97316;
    box-shadow:
        inset 0 0 8px #f97316,
        1px 1px 0 #000;
    transition: all 0.2s;
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    text-transform: uppercase;
    min-width: 32px;
    text-align: center;
    display: inline-block;
    text-decoration: none;
    position: relative;
    text-shadow: 0 0 3px #f97316;
    cursor: pointer;
    border-radius: 4px;
}

.retro-button-tiny:hover {
    transform: translate(-1px, -1px);
    box-shadow:
        inset 0 0 12px #f97316,
        2px 2px 0 #000;
    text-decoration: none;
    color: #fbbf24;
    border-color: #fb8c00;
}

.retro-button-tiny:active,
.retro-button-tiny.toggled {
    transform: translate(0px, 0px);
    box-shadow:
        inset 0 0 15px #f97316,
        0px 0px 0 #000;
    background: #2a2a2a;
    border-color: #fb8c00;
}

.retro-button-tiny.toggled {
    background: #f97316;
    color: #000;
    text-shadow: none;
}

/* Control Groups */
.control-group {
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid #f97316;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.control-title {
    color: #fbbf24;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-align: center;
    text-shadow: 0 0 5px #f97316;
    font-weight: bold;
    font-family: 'VT323', monospace;
}

/* Retro Select Dropdown */
.retro-select {
    background: #1a1a1a;
    color: #fbbf24;
    border: 2px solid #f97316;
    padding: 0.5rem;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    box-shadow: inset 0 0 10px rgba(249, 115, 22, 0.3);
    border-radius: 4px;
}

.retro-select:focus {
    outline: none;
    box-shadow:
        inset 0 0 10px rgba(249, 115, 22, 0.3),
        0 0 10px rgba(249, 115, 22, 0.5);
}

.retro-select option {
    background: #1a1a1a;
    color: #fbbf24;
}

/* Canvas Styling */
#main-canvas {
    cursor: crosshair;
    background: #000;
}

/* Responsive canvas container */
.cropper-canvas {
    height: clamp(320px, 45vh, 560px);
}

/* Keep control panel from forcing extra vertical space; make it scroll within canvas height */
.control-panel {
    max-height: clamp(320px, 45vh, 560px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #f4511e #1a1a1a; /* Firefox */
}

@media (min-width: 1024px) {
    .cropper-canvas {
        height: clamp(380px, 55vh, 640px);
    }
    .control-panel {
        max-height: clamp(380px, 55vh, 640px);
    }
}

/* WebKit custom scrollbar to match tools (Chrome Downloader) */
.control-panel::-webkit-scrollbar {
    width: 12px;
}

.control-panel::-webkit-scrollbar-track {
    background: #1a1a1a;
    border: 2px solid #f97316;
}

.control-panel::-webkit-scrollbar-thumb {
    background: #f4511e;
    border: 2px solid #fb8c00;
}

.control-panel::-webkit-scrollbar-thumb:hover {
    background: #fb8c00;
}

/* Drag and Drop Styling */
#cropper-canvas.drag-over #drop-overlay {
    opacity: 1 !important;
}

#drop-overlay {
    font-family: 'VT323', monospace;
    font-size: 2rem;
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
}

/* Control Panel Grid Layout */
@media (max-width: 1024px) {
    .control-panel {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .control-panel {
        grid-template-columns: 1fr;
    }

    .control-group {
        padding: 0.5rem;
    }

    .control-title {
        font-size: 0.8rem;
    }
}

/* Preview Items */
.preview-item canvas {
    transition: transform 0.2s ease;
}

.preview-item:hover canvas {
    transform: scale(1.05);
}

/* Preview item sizing: keep boxes tight around canvas */
.preview-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.preview-label {
    font-size: 0.85rem;
}

/* Themed range input */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #111;
    border: 1px solid #333;
    border-radius: 4px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #f97316;
    border: 2px solid #fb8c00;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(249, 115, 22, 0.6);
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #f97316;
    border: 2px solid #fb8c00;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(249, 115, 22, 0.6);
}

/* Focus styles */
.retro-button:focus-visible,
.retro-button-small:focus-visible,
.retro-button-tiny:focus-visible,
.retro-select:focus-visible,
input[type="range"]:focus-visible {
    outline: 2px dashed #fbbf24;
    outline-offset: 3px;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-text {
    color: #00ff00;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    text-shadow: 0 0 10px #00ff00;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Error Console (matching existing tools) */
.error-console-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.error-console {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    font-family: 'VT323', monospace;
    background-color: rgba(0, 0, 0, 0.95);
    color: #ff3333;
    border: 2px solid #ff3333;
    padding: 2rem;
    white-space: pre-wrap;
    text-shadow: 0 0 5px #ff3333;
    animation: errorBlink 1s infinite;
    min-width: 500px;
    max-width: 800px;
}

.error-console::before {
    content: "ERROR:\\> ";
    color: #ff6666;
}

@keyframes errorBlink {
    0%, 100% {
        border-color: #ff3333;
        box-shadow: 0 0 5px #ff3333;
    }
    50% {
        border-color: #ff6666;
        box-shadow: 0 0 15px #ff3333;
    }
}

/* Add scanlines effect to error console */
.error-console::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.2),
        rgba(0, 0, 0, 0.2) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    animation: scan 10s linear infinite;
}

@keyframes scan {
    from { background-position: 0 0; }
    to { background-position: 0 20px; }
}

/* Success Messages */
.success-message {
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 1rem;
    border-radius: 8px;
    text-shadow: 0 0 5px #00ff00;
    font-family: 'VT323', monospace;
    text-align: center;
    margin: 1rem 0;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .cropper-terminal {
        padding: 0.5rem;
    }

    .terminal-header {
        font-size: 1.2rem;
    }

    .control-panel {
        gap: 0.5rem;
    }

    .bg-gray-800.p-4 {
        padding: 0.75rem;
    }

    .preview-grid {
        gap: 0.5rem;
    }

    .preview-item {
        padding: 0.25rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .retro-button-small {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    .retro-select {
        min-height: 44px;
    }

    input[type="range"] {
        min-height: 44px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .retro-button-small {
        border-width: 3px;
    }

    .cropper-terminal {
        border-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .retro-button-small {
        transition: none;
    }

    .preview-item canvas {
        transition: none;
    }

    #drop-overlay {
        transition: none;
    }

    .loading-text {
        animation: none;
    }

    .cropper-terminal::before {
        animation: none;
    }

    .error-console::after {
        animation: none;
    }
}

/* Gradient Editor Dialog - Retro DOHMBOY64 Styling */
.gradient-editor-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.gradient-editor-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #f97316;
    border-radius: 12px;
    box-shadow:
        0 0 30px rgba(249, 115, 22, 0.5),
        inset 0 0 20px rgba(249, 115, 22, 0.1);
    min-width: 800px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    font-family: 'VT323', monospace;
}

.gradient-editor-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    animation: dialogScanlines 12s linear infinite;
}

@keyframes dialogScanlines {
    0% { background-position: 0 0; }
    100% { background-position: 0 30px; }
}

.gradient-editor-header {
    background: linear-gradient(90deg, #1a1a1a, #2a2a2a);
    border-bottom: 2px solid #f97316;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.gradient-editor-header h2 {
    color: #fbbf24;
    text-shadow: 0 0 10px #f97316;
    font-size: 1.5rem;
    margin: 0;
    font-weight: normal;
}

.gradient-editor-close {
    background: none;
    border: none;
    color: #f97316;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.gradient-editor-close:hover {
    background: rgba(249, 115, 22, 0.2);
    color: #fff;
}

.gradient-editor-content {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.gradient-preview-section,
.gradient-controls-section {
    flex: 1;
}

.gradient-preview-section h3,
.gradient-controls-section h3 {
    color: #fbbf24;
    text-shadow: 0 0 8px #f97316;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
    border-bottom: 1px solid #f97316;
    padding-bottom: 0.5rem;
}

#gradient-preview-canvas {
    display: block;
    margin: 0 auto 1rem;
    border: 2px solid #f97316;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
    background: #000;
}

.gradient-info {
    display: flex;
    justify-content: space-between;
    color: #00ff00;
    font-size: 0.9rem;
    text-shadow: 0 0 5px #00ff00;
}

.control-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid #333;
    border-radius: 6px;
}

.control-group label {
    display: block;
    color: #fbbf24;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 5px #f97316;
    font-weight: bold;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 0.5rem;
}

#angle-value {
    color: #00ff00;
    text-shadow: 0 0 5px #00ff00;
    font-size: 1rem;
}

#gradient-stops-list {
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
}

.gradient-stop-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(42, 42, 42, 0.8);
    border-radius: 4px;
    border: 1px solid #666;
}

.gradient-stop-item.current {
    border-color: #f97316;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.3);
}

.gradient-stop-color {
    width: 30px;
    height: 30px;
    border: 2px solid #f97316;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(249, 115, 22, 0.2);
}

.gradient-stop-position {
    color: #00ff00;
    font-size: 0.8rem;
    min-width: 40px;
    text-shadow: 0 0 3px #00ff00;
}

.gradient-stop-remove {
    background: #ff3333;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.gradient-stop-remove:hover {
    background: #ff6666;
    transform: scale(1.1);
}

.button-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#gradient-presets {
    width: 100%;
    background: #1a1a1a;
    color: #fbbf24;
    border: 2px solid #f97316;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

#gradient-presets:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

#gradient-presets option {
    background: #1a1a1a;
    color: #fbbf24;
}

.gradient-editor-footer {
    background: linear-gradient(90deg, #1a1a1a, #2a2a2a);
    border-top: 2px solid #f97316;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .gradient-editor-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .gradient-editor-dialog {
        min-width: 90vw;
        max-width: 95vw;
    }
}

@media (max-width: 768px) {
    .gradient-editor-header h2 {
        font-size: 1.2rem;
    }

    .gradient-editor-content {
        padding: 1rem;
    }

    .control-group {
        padding: 0.75rem;
    }

    .gradient-editor-footer {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .gradient-editor-footer .retro-button {
        width: 100%;
    }
}

/* Print Styles (hide interactive elements) */
@media print {
    .retro-button,
    .retro-button-small,
    .control-panel,
    #image-upload,
    #download-btn {
        display: none !important;
    }

    .cropper-terminal {
        border: 1px solid #000;
        box-shadow: none;
    }

    .terminal-header {
        color: #000 !important;
        text-shadow: none;
    }
}
