/* みんなの黒板 - Everyone's Blackboard Styles */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Noto Sans JP', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #ffffff;
    color: #333;
    overflow: hidden;
    height: 100vh;
    user-select: none;
    /* Enable font features for Japanese text */
    font-feature-settings: "palt" 1, "pkna" 1;
    text-rendering: optimizeLegibility;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.app-header {
    background: #2196F3;
    color: white;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

.app-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.room-info {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-indicator {
    font-size: 0.8rem;
    transition: color 0.3s;
}

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

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

.status-indicator.connecting {
    color: #FF9800;
    animation: pulse 1s infinite;
}

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

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tool Palette */
.tool-palette {
    background: white;
    width: 250px;
    min-width: 250px;
    border-right: 1px solid #e0e0e0;
    padding: 1rem;
    overflow-y: auto;
    z-index: 100;
}

.tool-section {
    margin-bottom: 1.5rem;
}

.tool-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-button {
    width: 3rem;
    height: 3rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-button svg {
    width: 1.5rem;
    height: 1.5rem;
    color: #666;
}

.tool-button:hover {
    border-color: #2196F3;
    background: #f8f9fa;
}

.tool-button.active {
    border-color: #2196F3;
    background: #2196F3;
}

.tool-button.active svg {
    color: white;
}

/* Color Controls */
.color-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#color-picker {
    width: 100%;
    height: 2.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
}

.color-preset {
    width: 2rem;
    height: 2rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: #2196F3;
}

/* Stroke Controls */
.stroke-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

#stroke-width {
    flex: 1;
}

#stroke-width-value {
    font-weight: 600;
    min-width: 2ch;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.action-button svg {
    width: 1rem;
    height: 1rem;
}

.action-button:hover {
    background: #f8f9fa;
    border-color: #2196F3;
}

.action-button.danger {
    color: #d32f2f;
}

.action-button.danger:hover {
    background: #ffebee;
    border-color: #d32f2f;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* User List */
.user-list {
    max-height: 200px;
    overflow-y: auto;
}

.user-item {
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
}

.user-indicator.inactive {
    background: #ccc;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    background: #ffffff !important;
    overflow: hidden;
}

.drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    touch-action: none;
    background: #ffffff !important;
}

.cursor-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
    background: transparent !important;
}

/* Text Input Overlay */
.text-input-overlay {
    position: absolute;
    z-index: 100;
    pointer-events: auto;
}

.text-input-overlay.hidden {
    display: none;
}

/* Disable canvas interactions when text input is active */
.canvas-container.text-input-active #main-canvas,
.canvas-container.text-input-active #cursor-canvas {
    pointer-events: none !important;
}

.text-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.text-input {
    border: 1px solid #e0e0e0;
    background: white;
    padding: 8px 12px;
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", Arial, sans-serif;
    outline: none;
    min-width: 200px;
    border-radius: 4px;
    transition: border-color 0.2s;
    /* IME optimization */
    ime-mode: active;
    /* Disable spell check and autocorrect for Japanese input */
    autocomplete: off;
    autocorrect: off;
    autocapitalize: none;
    spellcheck: false;
    /* Enable Japanese font features */
    font-feature-settings: "palt" 1, "pkna" 1;
    text-rendering: optimizeLegibility;
    /* Better line height for Japanese text */
    line-height: 1.4;
}

.text-input:focus {
    border-color: #2196F3;
}

.text-confirm-btn {
    background: #4CAF50;
    border: none;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    min-width: 36px;
    height: 36px;
}

.text-confirm-btn:hover {
    background: #45a049;
    transform: scale(1.05);
}

.text-confirm-btn:active {
    transform: scale(0.95);
}

.text-cancel-btn {
    background: #f44336;
    border: none;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    min-width: 36px;
    height: 36px;
}

.text-cancel-btn:hover {
    background: #da190b;
    transform: scale(1.05);
}

.text-cancel-btn:active {
    transform: scale(0.95);
}

.text-ttl-display {
    font-size: 12px;
    color: #666;
    padding: 0 8px;
    white-space: nowrap;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #2196F3;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Buttons */
.primary-button,
.secondary-button,
.danger-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.primary-button {
    background: #2196F3;
    color: white;
}

.primary-button:hover {
    background: #1976D2;
}

.secondary-button {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e0e0e0;
}

.secondary-button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.danger-button {
    background: #d32f2f;
    color: white;
}

.danger-button:hover {
    background: #b71c1c;
}

/* Error Messages */
.error-message {
    background: #ffebee;
    color: #d32f2f;
    padding: 0.75rem;
    border-radius: 4px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.error-message.hidden {
    display: none;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);  /* More transparent background */
    backdrop-filter: blur(2px);  /* Subtle blur effect */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.3s ease;
}

.loading-indicator.hidden {
    display: none;
}

.loading-indicator.connecting {
    background: rgba(0, 0, 0, 0.3);  /* Dark transparent overlay during connection */
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(224, 224, 224, 0.8);
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-indicator p {
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .tool-palette {
        width: 200px;
        min-width: 200px;
        padding: 0.75rem;
    }
    
    .tool-section {
        margin-bottom: 1rem;
    }
    
    .tool-button {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .tool-button svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .app-title {
        font-size: 1rem;
    }
    
    .room-info {
        font-size: 0.8rem;
    }
    
    .connection-status {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .tool-palette {
        position: fixed;
        top: 60px;
        left: -200px;
        height: calc(100vh - 60px);
        z-index: 1500;
        background: white;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        transition: left 0.3s;
    }
    
    .tool-palette.open {
        left: 0;
    }
    
    .canvas-container {
        width: 100%;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Font Loading Optimization */
@font-face {
    font-family: 'Noto Sans JP Fallback';
    font-display: swap;
    src: local('Noto Sans JP'), local('Yu Gothic'), local('Hiragino Sans');
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.ime-composing {
    background: rgba(239, 246, 255, 0.9) !important;
    border-bottom: 2px dashed #2196F3 !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* IME Overlay Styles */
.ime-overlay-container {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
    user-select: none;
}

.ime-composition-display {
    background: rgba(239, 246, 255, 0.95);
    border: 2px solid #2196F3;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 16px;
    color: #1E40AF;
    min-width: 100px;
    min-height: 24px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: pre-wrap;
    line-height: 1.4;
    font-feature-settings: "palt" 1, "pkna" 1;
    text-rendering: optimizeLegibility;
}

.ime-composition-display.composing {
    border-bottom-style: dashed;
    animation: imeCompositionPulse 1.5s infinite ease-in-out;
}

@keyframes imeCompositionPulse {
    0% { border-color: #2196F3; transform: translateY(0); }
    50% { border-color: #3B82F6; transform: translateY(-1px); }
    100% { border-color: #2196F3; transform: translateY(0); }
}

.ime-composition-display.confirmed {
    background: rgba(209, 250, 229, 0.95);
    border-color: #10B981;
    animation: imeConfirmed 0.5s ease;
}

@keyframes imeConfirmed {
    0% { transform: scale(1); background: rgba(239, 246, 255, 0.95); }
    50% { transform: scale(1.05); background: rgba(209, 250, 229, 0.95); }
    100% { transform: scale(1); background: rgba(209, 250, 229, 0.95); }
}

/* Japanese Text Optimization */
.japanese-text {
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
    font-feature-settings: "palt" 1, "pkna" 1;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
}

/* Input Method Indicator */
.ime-mode-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: #2196F3;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.3s;
}

.ime-mode-indicator.active {
    opacity: 1;
}

/* Remote Typing Animation */
@keyframes remoteTypingPulse {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* Mobile IME Support */
@media (max-width: 768px) {
    .text-input {
        /* Better mobile IME support */
        -webkit-appearance: none;
        border-radius: 4px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ime-composition-display {
        font-size: 18px;
        min-width: 120px;
        min-height: 28px;
    }
}

/* Dark Theme Support - Disabled to maintain white background */
/* @media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #e0e0e0;
    }
    
    .tool-palette {
        background: #1e1e1e;
        border-color: #333;
    }
    
    .canvas-container {
        background: #1e1e1e;
    }
    
    .modal-content {
        background: #1e1e1e;
        color: #e0e0e0;
    }
    
    .ime-composition-display {
        background: rgba(31, 41, 55, 0.95);
        border-color: #4F46E5;
        color: #E5E7EB;
    }
    
    .ime-composition-display.confirmed {
        background: rgba(6, 78, 59, 0.95);
        border-color: #059669;
    }
} */