/* =============================================
   🎨 Pintura - Tema Oscuro Moderno
   Inspirado en Confesiones Anónimas / Discord
   ============================================= */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    height: 100vh;
    padding: 12px 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Fondo animado con partículas/papeles */
#paper-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.paper {
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(88, 101, 242, 0.15);
    border-radius: 50%;
    animation: float 15s infinite ease-in-out;
}

@keyframes float {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) rotate(720deg);
        opacity: 0;
    }
}

/* Contenedor principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

/* Back link */
.back-link {
    text-align: center;
    margin-bottom: 15px;
}

.back-link a {
    color: #5865f2;
    text-decoration: none;
    font-size: 15px;
    transition: color 0.3s ease;
}

.back-link a:hover {
    color: #7983f5;
    text-decoration: underline;
}

/* Títulos */
h1 {
    color: #ffffff;
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

h1 .emoji {
    font-size: 2.4rem;
}

h2 {
    color: #ffffff;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Tarjetas / Form Container */
.form-container {
    background: #16213e;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    border: 1px solid rgba(88, 101, 242, 0.15);
    transition: box-shadow 0.3s ease;
    flex-shrink: 0;
}

.form-container:hover {
    box-shadow: 0 8px 32px rgba(88, 101, 242, 0.15);
}

/* Input Group */
.input-group {
    margin-bottom: 10px;
}

.input-group label {
    display: block;
    color: #b0b0b0;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #2a2a4a;
    border-radius: 8px;
    font-size: 1rem;
    background: #1a1a2e;
    color: #e0e0e0;
    transition: border-color 0.3s ease;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #5865f2;
}

.input-group input[type="text"]::placeholder {
    color: #555;
}

/* Brush Group */
.brush-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.brush-group label {
    color: #b0b0b0;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.brush-group input[type="range"] {
    cursor: pointer;
    accent-color: #5865f2;
    height: 6px;
}

.brush-group span {
    color: #888;
    min-width: 40px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Color Picker */
.color-picker-wrapper {
    position: relative;
    display: inline-block;
}

.color-picker-btn {
    width: 44px;
    height: 36px;
    border: 3px solid #2a2a4a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-picker-btn:hover {
    border-color: #5865f2;
    transform: scale(1.08);
}

.color-picker-btn.current-color {
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.3);
}

.color-palette {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    background: #16213e;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 100;
    width: 290px;
    border: 1px solid rgba(88, 101, 242, 0.2);
}

.color-palette.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.color-palette h4 {
    color: #b0b0b0;
    margin-bottom: 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 15px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.18);
    border-color: #fff;
}

.color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px #5865f2;
}

.color-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #2a2a4a;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.color-input-row input[type="text"]:focus {
    outline: none;
    border-color: #5865f2;
}

.color-input-row input[type="color"] {
    width: 40px;
    height: 36px;
    border: none;
    cursor: pointer;
    background: transparent;
    border-radius: 4px;
}

/* Botones */
.tool-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

button:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #5865f2;
    color: white;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

.btn-primary:hover {
    background: #4752c4;
    box-shadow: 0 4px 20px rgba(88, 101, 242, 0.5);
}

.btn-secondary {
    background: #4f545c;
    color: white;
}

.btn-secondary:hover {
    background: #686d73;
}

.btn-danger {
    background: #ed4245;
    color: white;
    box-shadow: 0 4px 15px rgba(237, 66, 69, 0.2);
}

.btn-danger:hover {
    background: #d83c3f;
    box-shadow: 0 4px 20px rgba(237, 66, 69, 0.4);
}

.btn-info {
    background: #3ba55d;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 165, 93, 0.2);
}

.btn-info:hover {
    background: #2d8049;
    box-shadow: 0 4px 20px rgba(59, 165, 93, 0.4);
}

/* Canvas Wrapper */
.canvas-wrapper {
    background: #16213e;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(88, 101, 242, 0.15);
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#drawingCanvas {
    border: 2px solid #2a2a4a;
    border-radius: 8px;
    cursor: crosshair;
    display: block;
    background: #ffffff;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 28px;
    right: 28px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zoom-controls button {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #5865f2;
    color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.zoom-controls button:hover {
    background: #4752c4;
}

.zoom-controls #zoomLevel {
    color: #aaa;
    font-size: 0.7rem;
    text-align: center;
    font-weight: 600;
    user-select: none;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 380px;
    animation: toastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.toast:hover {
    transform: scale(1.02);
}

.toast.removing {
    animation: toastOut 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.toast .toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast .toast-text {
    flex: 1;
}

.toast .toast-close {
    font-size: 1rem;
    opacity: 0.6;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.toast .toast-close:hover {
    opacity: 1;
}

.toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 10px 10px;
    animation: toastProgress 3s linear forwards;
}

.toast.success {
    background: #16213e;
    color: #57f287;
    border: 1px solid rgba(59, 165, 93, 0.4);
}

.toast.success .toast-progress {
    background: #3ba55d;
}

.toast.error {
    background: #16213e;
    color: #ed4245;
    border: 1px solid rgba(237, 66, 69, 0.4);
}

.toast.error .toast-progress {
    background: #ed4245;
}

.toast.info {
    background: #16213e;
    color: #5865f2;
    border: 1px solid rgba(88, 101, 242, 0.4);
}

.toast.info .toast-progress {
    background: #5865f2;
}

@keyframes toastIn {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Shortcuts */
.shortcuts {
    color: #555;
    text-align: center;
    margin-top: 6px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.shortcuts kbd {
    background: rgba(88, 101, 242, 0.15);
    color: #8891f2;
    padding: 3px 8px;
    border-radius: 4px;
    margin: 0 3px;
    font-size: 0.8rem;
    border: 1px solid rgba(88, 101, 242, 0.2);
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #2a2a4a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5865f2;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1.6rem;
    }

    .form-container {
        padding: 18px;
    }

    .api-config {
        flex-direction: column;
        align-items: flex-start;
    }

    .api-config input {
        width: 100%;
    }

    .tool-buttons {
        justify-content: center;
    }

    .tool-buttons button {
        flex: 1;
        min-width: 120px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .brush-group {
        gap: 10px;
    }

    #drawingCanvas {
        width: 100% !important;
        height: auto !important;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .tool-buttons button {
        min-width: 100px;
        font-size: 0.8rem;
    }
}
