/* style.css */
body {
    font-family: 'JetBrains Mono', monospace;
    background-color: #f0f0f0; 
    color: #f0f0f0;
    overflow: hidden;
    display: flex; 
    font-size: 14px; 
    font-weight: 400; 
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #111;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Login screen styles */
#login-view {
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.login-box {
    background-color: #111; 
    border: 1px solid #333;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

#password-view {
    background-color: #000;
}
#password-view .login-box {
    background-color: transparent; 
    border: none;
    box-shadow: none;
}

/* --- LOGIN SCREEN INPUT STYLE --- */
.login-input {
    font-family: 'JetBrains Mono', monospace;
    background-color: #ffffff; 
    border: 2px solid #888; 
    color: #000000; 
    padding: 0.3rem; /* from 0.75rem - 0.3rem*/
    border-radius: 8px;
    transition: all 0.2s ease;
}
.login-input:focus {
    outline: none;
    border-color: #aaa;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* --- CHAT SCREEN STYLES --- */

/* NEW: Align the input form with the chat messages */
#message-form {
    max-width: 36rem;       /* Matches .message-entry width */
	
	/* ADD THIS LINE: Ensures it fills the screen on mobile phones */
    width: 100%;
	
    margin: 0 auto;         /* Centers the form */
    display: flex;          /* Aligns Input and Menu Icon side-by-side */
    align-items: center;    
    gap: 10px;              
    padding-left: 5px;      
    padding-right: 5px;
    position: relative;
}

.drrr-input {
    font-family: 'JetBrains Mono', monospace;
    background-color: #ffffff; 
    border: 1px solid #ccc; 
    color: #000000; 
    padding: 0.75rem;
    border-radius: 4px; 
    transition: all 0.2s ease;
    resize: none; 
    
    /* NEW: Ensure it has a good minimum height & fills space */
    min-height: 50px; 
    flex-grow: 1; /* Stretches to fill the form width */
}

.drrr-input:focus {
    outline: none; 
    box-shadow: none; 
    border-color: #aaa; 
}

/* Update .drrr-btn to this: */

.drrr-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem; 
    font-weight: bold;
    color: #000000; 
    background-color: #d3d3d3; 
    border: 2px solid #aaa; 
    padding: 0.2rem 2rem; /* 0.25rem 3.5rem */ 
    border-radius: 9999px; 
    text-align: center;
    
    /* --- FIX STARTS HERE --- */
    display: block;           /* changed from inline-block */
    width: fit-content;       /* Only as wide as it needs to be + padding */
    min-width: 120px;         /* Ensures it looks like the wide pill in screenshot - 200px */
    margin: -5px auto 0;    /* Centers the button horizontally - 0.5rem auto 0 - - change to px */
    /* --- FIX ENDS HERE --- */
	transform: translateX(-25px); /* moves to the left */
    
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.2);
}

.drrr-btn:hover {
    background-color: #e0e0e0; 
    border-color: #000; 
}

.drrr-btn:disabled {
    background-color: #a0a0a0; 
    color: #555;
    cursor: not-allowed;
    border-color: #000; 
}

/* --- ICON PICKER STYLES (OPTIMIZED & ACCESSIBLE) --- */
.icon-swatch {
    width: 60px; 
    height: 60px; 
    border-radius: 0px; 
    cursor: pointer;
    
    /* Transparent border so unselected icons look clean */
    border: 3px solid transparent; 
    
    /* PERFORMANCE FIXES: Hardware Acceleration */
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.15s ease;
    will-change: transform; 
    transform: translateZ(0); 
    backface-visibility: hidden; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000; 
    overflow: hidden; 
}

.icon-swatch img {
    pointer-events: none; 
    will-change: transform;
}

/* Combine Hover AND Focus styles so keyboard users see the "Pop" */
.icon-swatch:hover {
    border-color: #ffffff; 
    transform: scale(1.15); 
    z-index: 10; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); 
    outline: none; 
}

.icon-swatch.selected {
    transform: scale(1.1);
    border-color: #ffffff; 
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    z-index: 5;
}

/* --- CHAT VIEW STYLES --- */
#chat-view {
    background-color: #000; 
    width: 100%;
    height: 100%; /* % */
	
}

#chat-window {
    background-color: #000; 
    padding: 1rem;
    
    /* Optional: Smooth scrolling */
    scroll-behavior: smooth;
}

.message-entry {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    max-width: 36rem; 
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

/* WIDER COLUMN for Names (Safety against overlap) */
.icon-name-block {
    width: 70px; 
    margin-right: 20px; /* CHANGED: Increased from 8px to 20px to add space */
    flex-shrink: 0; 
    text-align: center;
    padding-top: 5px; 
    display: flex;
    flex-direction: column;
    align-items: center;
}

img.user-icon-svg { 
    width: 50px; 
    height: 50px; 
    border-radius: 0px !important; 
    display: inline-block; 
    object-fit: cover; 
    border: 2px solid #fff; 
}

/* USERNAME STYLING */
.chat-username {
    font-size: 0.7rem; 
    color: #aaa;
    margin-top: 2px;
    
    /* Force single line, but handle long names */
    white-space: nowrap; 
    overflow: visible; 
    text-overflow: clip;
    line-height: 1.1;
    width: 100%;
}

/* --- MESSAGE BUBBLE (ANIME ACCURATE) --- */
.message-bubble {
    position: relative;
    background: linear-gradient(180deg, var(--user-color-light, #fcf6c8) 0%, var(--user-color-dark, #c6b03f) 100%);
    color: #ffffff; 
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4); 
    
    padding: 13px 25px; /*10px 18px*/
    border-radius: 13px; 
    border: 3px solid #fff; 
    
    /* Calculated Width (100% - Column Width - Margins) */
    max-width: calc(100% - 170px); /* (100% - 110px) */
    
    box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.2); 
    margin-top: 4px; 
}

/* White Border Arrow */
.message-bubble::before {
    content: '';
    position: absolute;
    left: -16px;  
    top: 12px;    
    width: 0;
    height: 0;
    border-top: 8px solid transparent; 
    border-bottom: 8px solid transparent; 
    border-right: 16px solid #fff; 
    z-index: 1;
}

/* Colored Fill Arrow */
.message-bubble::after {
    content: '';
    position: absolute;
    left: -9px; 
    top: 15px;   
    width: 0;
    height: 0;
    border-top: 5px solid transparent; 
    border-bottom: 5px solid transparent; 
    border-right: 10px solid var(--user-color-dark, #c6b03f); 
    z-index: 2;
}

.message-bubble p {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.message-action {
    text-align: center;
    font-style: italic;
    opacity: 0.9;
    max-width: calc(100% - 120px);
}

.profile-display-btn {
    font-family: 'JetBrains Mono', monospace;
    background-color: #000; 
    border: none; 
    color: #f0f0f0;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    display: flex; 
    align-items: center;
}

.profile-display-btn:hover {
    background-color: #222; 
}

.profile-display-btn img.user-icon-svg { 
    margin-right: 8px; 
    width: 30px; 
    height: 30px;
    border-radius: 4px; 
    object-fit: cover; 
}

#chat-view header {
    background-color: #e0e0e0; 
    padding-top: 1rem; 
    padding-bottom: 1rem; 
    /* Add a bottom shadow so it looks like it sits "above" the chat */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    z-index: 20;
	position: relative;
}

/* NOTIFICATIONS (Aligned) */
.notification {
    color: #ffffff; 
    font-style: normal; 
    text-align: left; 
    
    /* Aligns with the left edge of the user icon */
    padding: 0.5rem 0 0.5rem 20px;
    
    display: flex;
    align-items: center;
    max-width: 36rem; 
    margin-left: auto;
    margin-right: auto;
}

.notification::before {
    content: '► ►'; 
    margin-right: 8px; 
    font-size: 1em; 
}

.notification i {
    font-style: normal;
}

#logout-button {
    margin: 0;
}

/* --- STYLES FOR PASSWORD SCREEN --- */
.drrr-logo-container {
    width: 240px; 
    height: 240px; 
    border: 4px solid white; 
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 2rem auto; 
    position: relative;
}

@media (min-width: 640px) { 
     .drrr-logo-container {
        width: 280px; 
        height: 280px;
     }
}

.drrr-logo-container::before {
    content: '';
    position: absolute;
    width: calc(100% - 24px); 
    height: calc(100% - 24px); 
    border: 8px solid white; 
    border-radius: 50%;
}

.drrr-logo-image {
    width: 190px; 
    height: 190px; 
    object-fit: contain;
}

@media (min-width: 640px) { 
    .drrr-logo-image {
        width: 230px; 
        height: 230px;
    }
}

#password-input {
    background-color: #5a5a5a; 
    border: 1px solid #888; 
    border-radius: 9999px; 
    text-align: center;
    font-size: 1rem; 
    padding: 0.25rem 1rem; 
    box-shadow: none;
    color: #f0f0f0;
    width: 100%; 
}

#password-input::placeholder {
    color: #ccc;
}

#password-input:focus {
    outline: none;
    border-color: #aaa;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

#password-btn {
    font-family: 'JetBrains Mono', monospace;
    background: #808080; 
    border: 1px solid #fff; 
    border-radius: 9999px; 
    color: #ffffff; 
    padding: 0.5rem 1.5rem; 
    font-size: 1rem; 
    box-shadow: none;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
    cursor: pointer;
    font-weight: bold;
}

#password-btn:hover {
    background: #909090; 
    border-color: #fff; 
}

#password-btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    border-color: #555;
}

.join-btn-drrr {
    font-family: 'JetBrains Mono', monospace;
    background: #808080; 
    border: 1px solid #fff; 
    border-radius: 9999px; 
    color: #ffffff; 
    padding: 0.2rem 1.5rem; /* from 0.5rem - 0.25rem vertical */
    font-size: 1rem; 
    box-shadow: none;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
    font-weight: bold;
}

.join-btn-drrr:hover {
    background: #909090; 
    border-color: #fff;
}

/* FIX: Make border white even when disabled */
.join-btn-drrr:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    border-color: #ffffff; /* FORCE WHITE BORDER */
}

#password-error {
    color: #f0f0f0 !important; 
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem; /* 1rem - 0.8rem */
    margin-top: 0.5rem; /* 1rem - 0.8rem */
    text-shadow: none !important; 
    font-weight: bold;
	
	/* --- ADD THESE TWO LINES --- */
    text-align: center; 
    width: 100%;
}

/* --- Animation --- */
@keyframes glowFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-5px);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-pop-animation {
    animation: glowFadeIn 0.35s ease-out forwards;
    will-change: transform, opacity;
}

/* Side Buttons (Logout & Sound) */
.side-icon-btn {
    background: transparent;
    border: none;
    color: #000000;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-icon-btn:hover {
    color: #555555;
    transform: scale(1.1);
}

.side-icon-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.hidden {
    display: none !important;
}

/* --- NEW: Icon Taken State for Icon Locking Feature --- */
.icon-taken {
    opacity: 0.3; /* Make it see-through */
    cursor: not-allowed; /* Show X cursor */
    filter: grayscale(100%); /* Optional: make it black and white */
}

/* --- MOBILE OPTIMIZATIONS (Reverted to Standard) --- */
@media (max-width: 768px) {
    
    /* 1. Adjust Layout for Mobile */
    body {
        flex-direction: column;
        height: 100vh;
    }

    /* 2. Chat Window Width */
    #chat-view, #login-view {
        width: 100%;
        height: 100%;
    }
    
    /* 3. Header Layout (Side-by-Side) */
    #chat-view header {
        padding: 0.25rem; /* Reduced from 0.5rem to give more width to the input */
        flex-direction: row;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    /* 4. Input Area */
    .drrr-input {
        font-size: 16px; /* Prevents iOS Zoom */
        padding: 10px;
    }

    #message-form {
        display: flex;
        gap: 5px;
        padding: 5px;
    }
    
    /* Input grows to fill available space */
    #message-input {
        flex-grow: 1;
        width: auto; 
    }

    /* 5. Icon Picker Grid */
    #icon-picker {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        max-height: 250px;
        overflow-y: auto;
        justify-items: center;
    }

    /* 6. Login Box Sizing */
    .login-box {
        width: 90%;
        padding: 1.5rem;
    }
    
    /* 7. Logo Sizing (Kept the fix you liked) */
    .drrr-logo-container {
        width: 180px;
        height: 180px;
    }
    .drrr-logo-image {
        width: 120px; /* Kept small to prevent touching borders */
        height: 120px;
    }

    /* 8. Message Widths */
    .message-entry, .notification {
        max-width: 95%; 
        padding-left: 5px;
        padding-right: 5px;
    }

    .message-bubble {
        max-width: calc(100% - 130px); 
    }
}
/* --- OEKAKI MODAL STYLES --- */
#drawing-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;
}

.drawing-container {
    background: #e0e0e0;
    border: 3px solid #fff;
    border-radius: 0px; /* from 4px to 0px */
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    width: auto;
    max-width: 95%;
}

.drawing-header {
    background: #333;
    color: #fff;
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    
    /* THIS IS THE KEY FIX: Pushes the text down to the middle */
    align-items: center;  
    
    font-weight: bold;
    min-height: 30px; /* Optional: ensures the bar is tall enough */
}

#draw-close-btn {
    background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer;
}

#paint-canvas {
    background: #cccccc; /*#fff */
    cursor: crosshair;
    display: block;
    /* Touch Action None is CRITICAL for mobile drawing */
    touch-action: none; 
}

.drawing-tools {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ccc;
    border-top: 1px solid #999;
}

.colors { display: flex; gap: 8px; }

.color-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid #999;
    cursor: pointer;
}

.color-dot.active { border-color: #fff; box-shadow: 0 0 0 2px #333; }

.actions button {
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid #333;
    background: #fff;
    cursor: pointer;
    padding: 4px 12px;
    margin-left: 5px;
    font-weight: bold;
	color: #000000; /* <--- ADD THIS LINE (Black Text) */
}

#send-drawing-btn {
    background: #333; color: #fff;
}

/* --- OEKAKI IMAGE DISPLAY STYLES (BLENDED) --- */
.message-bubble img {
    /* Limit size */
    max-width: 150px !important;  
    max-height: 150px !important; 
    
    width: auto !important;
    height: auto !important;
    
    object-fit: contain;
    
    /* REMOVED: border: 1px solid #333; */
    border: none !important; 
    
    /* Transparent background to let bubble color show through */
    background-color: transparent !important;
    
    margin: 2px 0;
    display: block;
    
    /* Optional: Slight opacity to make it look like marker ink */
    opacity: 0.9;
	
	/* ADD THIS LINE: Makes white ink visible on light backgrounds */
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.6));
}

/* --- UNIVERSAL DROPDOWN MENU STYLES (IRC ACCENTS) --- */

/* The Menu Box */
#dropdown-menu {
    position: absolute;
    top: 100%; 
    right: 0;
    margin-top: 0;
    
    /* 1. Background stays WHITE */
    background-color: #ffffff; 
    
    /* 2. Border becomes IRC GRAY */
    border: 2px solid #7F7F7F;
    
    border-radius: 0;       
    padding: 0;             
    
    display: flex; 
    flex-direction: column;
    gap: 0;                 
    min-width: 120px; /* 160px - 120px */
    
    /* Hard Shadow matches the gray border */
    box-shadow: none; 
    z-index: 100; 
}

/* Styling for buttons inside the menu */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    
    background: transparent;
    border: none;
    
    /* Divider lines are also IRC Gray */
    border-bottom: 1px solid #7F7F7F; 
    
    width: 100%;
    padding: 6px 10px; /* 12px 15px */
    
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: bold;
    color: #000;
    text-align: left;
    
    cursor: pointer;
    border-radius: 0;      
    transition: none;      
}

.menu-item:last-child {
    border-bottom: none;
}

/* 3. HOVER Highlight becomes IRC GRAY */
.menu-item:hover {
    background-color: #D2D2D2; /* #c0c0c0 */
    color: #000000; /* Text stays black for contrast on gray */
}

/* Optional: Keep icons black on gray background (no invert needed) */
.menu-item:hover img, 
.menu-item:hover svg {
    filter: none; 
}

.menu-item img, 
.menu-item svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Utilities */
#dropdown-menu.show {
    display: flex !important;
}

.hidden {
    display: none !important;
}

/* Not part of Dropdown, Add/Replace in style.css */
#user-action-menu {
    position: fixed;
    
    background-color: #ffffff;
    border: 2px solid #7F7F7F;   /* IRC Gray Border */
    border-radius: 0;            /* Sharp corners */
    padding: 0;                  /* Remove padding so buttons touch edges */
    
    display: flex;
    flex-direction: row;         /* Horizontal list */
    gap: 0;                      /* Remove gap so buttons touch each other */
    width: fit-content;
    min-width: auto;
    
    box-shadow: none;            /* Flat look */
    z-index: 9999;
}

/* Style for the buttons inside */
#user-action-menu .menu-item {
    padding: 8px 12px;           /* Comfortable click area */
    border-radius: 0;
    background: transparent;
    border: none;
    
    /* Vertical Divider Line between buttons */
    border-right: 1px solid #7F7F7F; /* #c0c0c0 */ 
    
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

/* Remove divider from the last button so it doesn't look weird */
#user-action-menu .menu-item:last-child {
    border-right: none;
}

/* Hover Effect: IRC Gray Background */
#user-action-menu .menu-item:hover {
    background-color: #D2D2D2; /* #c0c0c0 */
}

/* Force icons to be small & uniform */
#user-action-menu img {
    width: 20px !important;
    height: 20px !important;
    display: block;
    object-fit: contain;
}