/**
 * Desenho Colaborativo - Estilos CSS
 * Versão: 20250130015 - Correção dos resize handles para ficarem ao redor da imagem
 * Cache-Control: no-cache, no-store, must-revalidate
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Login Screen */
#loginScreen {
    justify-content: center;
    align-items: center;
}

.container {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 400px;
}

.container h1 {
    color: #333;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

.login-form h2 {
    color: #555;
    margin-bottom: 1.5rem;
}

.login-form input {
    width: 100%;
    padding: 1rem;
    margin: 0.5rem 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
}

.login-form button {
    width: 100%;
    padding: 1rem;
    margin: 0.5rem 0;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

#joinRoom {
    background: #667eea;
    color: white;
}

#joinRoom:hover {
    background: #5a6fd8;
}

#createRoom {
    background: #764ba2;
    color: white;
}

#createRoom:hover {
    background: #6a4190;
}

.divider {
    margin: 1rem 0;
    color: #888;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
    z-index: 1;
}

.divider {
    background: white;
    padding: 0 1rem;
    z-index: 2;
    position: relative;
}

/* Game Screen */
#gameScreen {
    background: #f0f2f5;
}

.header {
    background: #0090c9;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    z-index: 1000;
    color:white;
}

.room-info {
    display: flex;
    gap: 2rem;
    color: white;
}

.players-list {
    color: white;
}

.connection-status {
    color: white;
    font-weight: bold;
}

.connection-status #connectionStatus {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

.toolbar {
    background: white;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 50px;
    position: relative;
    z-index: 1000;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tool-group label {
    font-size: 0.85rem;
    color: #666;
    margin-right: 0.25rem;
}

.tool {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool:hover {
    border-color: #667eea;
}

.tool.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tool.danger {
    border-color: #ff4757;
    color: #ff4757;
}

.tool.danger:hover {
    background: #ff4757;
    color: white;
}

.tool.secondary {
    border-color: #747d8c;
    color: #747d8c;
}

.tool.secondary:hover {
    background: #747d8c;
    color: white;
}

.tool:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#brushSize {
    width: 80px;
    height: 20px;
}

#sizeDisplay {
    min-width: 15px;
    font-weight: bold;
    font-size: 0.85rem;
}

.color-group {
    position: relative;
}

.color-palette {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    position: relative;
}

#colorPicker {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.preset-colors {
    position: absolute;
    top: 35px;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    max-width: 200px;
}

.preset-colors.hidden {
    display: none;
}

.color-btn {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid rgba(0,0,0,0.1);
}

.color-btn:hover {
    transform: scale(1.2);
}

.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: #f0f2f5;
    position: relative;
    transform-origin: top left;
}

#drawingCanvas {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
    position: relative;
    z-index: 10;
}

/* Floating Images Container */
.floating-images-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.floating-image {
    position: absolute;
    pointer-events: none;
    user-select: none;
    z-index: 101;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Image Upload Overlay */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.image-overlay.active {
    pointer-events: all;
}

.image-container {
    position: absolute;
    display: inline-block;
}

.overlay-image {
    position: relative;
    border: 2px dashed #667eea;
    cursor: move;
    min-width: 50px;
    min-height: 50px;
    max-width: 90vw;
    max-height: 90vh;
    user-select: none;
    z-index: 201;
    transition: border-color 0.2s ease;
    display: block;
}

.overlay-image:hover {
    border-color: #5a6fd8;
    border-width: 3px;
}

.image-controls {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: flex;
    gap: 0.5rem;
    z-index: 202;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.control-btn.confirm {
    background: #27ae60;
    color: white;
}

.control-btn.confirm:hover {
    background: #2ecc71;
    transform: scale(1.1);
}

.control-btn.cancel {
    background: #e74c3c;
    color: white;
}

.control-btn.cancel:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 202;
}

.resize-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #667eea;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: pointer;
    z-index: 203;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.resize-handle:hover {
    background: #5a6fd8;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.resize-handle.nw {
    top: -10px;
    left: -10px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -10px;
    right: -10px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -10px;
    left: -10px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -10px;
    right: -10px;
    cursor: se-resize;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        text-align: center;
        padding: 0.5rem;
    }

    .toolbar {
        padding: 0.4rem 0.8rem;
        gap: 0.8rem;
        min-height: 45px;
    }

    .tool-group {
        justify-content: center;
        gap: 0.2rem;
    }

    .container {
        min-width: 300px;
        margin: 1rem;
    }
    
    .tool {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
        min-height: 28px;
    }
    
    #brushSize {
        width: 60px;
        height: 18px;
    }
    
    .tool-group label {
        font-size: 0.8rem;
    }
    
    #colorPicker {
        width: 26px;
        height: 26px;
    }
    
    .preset-colors {
        max-width: 150px;
        padding: 0.4rem;
    }
    
    .color-btn {
        width: 18px;
        height: 18px;
    }
    
    /* Resize handles para dispositivos móveis - maiores e mais fáceis de tocar */
    .resize-handle {
        width: 28px;
        height: 28px;
        border: 4px solid white;
    }
    
    .resize-handle.nw {
        top: -14px;
        left: -14px;
    }
    
    .resize-handle.ne {
        top: -14px;
        right: -14px;
    }
    
    .resize-handle.sw {
        bottom: -14px;
        left: -14px;
    }
    
    .resize-handle.se {
        bottom: -14px;
        right: -14px;
    }
    
    /* Imagem overlay mais responsiva no mobile */
    .overlay-image {
        border: 3px dashed #667eea;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}

/* Loading animation */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Connection status styles */
.connected #connectionStatus {
    background: #27ae60;
    color: white;
}

.connected #connectionStatus::before {
    content: '🟢 ';
}

.disconnected #connectionStatus {
    background: #e74c3c;
    color: white;
}

.disconnected #connectionStatus::before {
    content: '🔴 ';
}

/* Image Selection Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #e9ecef;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

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

.image-option {
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
    background: white;
}

.image-option:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-option.selected {
    border-color: #667eea;
    background: #f0f3ff;
}

.image-preview {
    width: 100%;
    height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
}

.image-preview img {
    max-width: 100%;
    max-height: 104px;
    object-fit: contain;
}

.upload-option .image-preview {
    background: #f8f9fa;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.upload-text {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .image-options {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }
    
    .image-preview {
        height: 104px;
    }
    
    .image-preview img {
        max-height: 78px;
    }
}
