/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    background-color: #f0f0f0;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-user-select: none;
    user-select: none;
}

/* Login modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.login-modal.hidden {
    display: none;
}

.login-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.login-content h2 {
    margin-bottom: 16px;
    color: #333;
    font-size: 24px;
}

.login-content p {
    margin-bottom: 24px;
    color: #666;
    font-size: 14px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#loginForm input[type="password"] {
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

#loginForm input[type="password"]:focus {
    outline: none;
    border-color: #4caf50;
}

#loginForm button {
    padding: 12px 24px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#loginForm button:hover {
    background: #45a049;
}

#loginForm button:active {
    background: #3d8b40;
}

.login-error {
    color: #f44336;
    font-size: 14px;
    min-height: 20px;
}

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

/* Toolbar */
.toolbar {
    background: #f8f8f8;
    border-bottom: 1px solid #ccc;
    padding: 4px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.toolbar-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
}

.toolbar-row:first-child {
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
    margin-bottom: 2px;
}

.toolbar-separator {
    width: 1px;
    height: 40px;
    background: #ccc;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
    margin-left: auto;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    transition: background-color 0.3s;
}

.status-indicator.connected {
    background-color: #4caf50;
}

.status-indicator.disconnected {
    background-color: #f44336;
}

.status-indicator.connecting {
    background-color: #ff9800;
}

.color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-btn {
    width: 40px;
    height: 40px;
    border: 3px solid #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.color-btn.selected {
    border-color: #333;
    border-width: 4px;
    transform: scale(1.05);
}

.color-btn.selected::after {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: #333;
    border-radius: 50%;
    border: 2px solid #fff;
}

.tool-buttons {
    display: flex;
    gap: 8px;
}

.brush-widths {
    display: flex;
    gap: 6px;
    align-items: center;
}

.brush-width-btn {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.brush-width-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.brush-width-btn.selected {
    border-color: #333;
    background: #f0f0f0;
}

.brush-width-btn .width-indicator {
    background: #333;
    border-radius: 50%;
}

.action-buttons {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.tool-btn {
    width: 44px;
    height: 44px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #555;
}

.tool-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.tool-btn:active {
    background: #e0e0e0;
}

.tool-btn.selected {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

/* Active users bar */
.users-bar {
    background: #f8f8f8;
    border-bottom: 1px solid #ccc;
    padding: 6px 16px;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.active-users {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.active-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #ddd;
}

.active-user-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Canvas container */
.canvas-container {
    flex: 1;
    position: relative;
    background: #fff;
    overflow: hidden;
}

#drawCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

#drawCanvas.breakout-mode {
    cursor: pointer;
}

/* Footer */
.footer {
    background: #f8f8f8;
    border-top: 2px solid #ccc;
    padding: 8px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
    font-size: 14px;
    color: #333;
    min-height: 44px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

#userName {
    font-weight: 600;
    color: #000;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    background: #fff;
    border: 2px solid #ddd;
    transition: all 0.2s;
}

#userName:hover {
    background-color: #e8f5e9;
    border-color: #4caf50;
}

#userName:active {
    transform: scale(0.98);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .toolbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .color-btn {
        width: 36px;
        height: 36px;
    }

    .tool-btn {
        width: 40px;
        height: 40px;
    }

    .users-bar {
        padding: 8px 12px;
    }

    .footer {
        padding: 10px 12px;
        min-height: 50px;
    }

    #userName {
        font-size: 16px;
        font-weight: 700;
    }
}

/* Loading state */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #999;
}

/* Toast notifications (for future use) */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}
