/* Reset et styles de base */
body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    height: 100%;
}

/* Conteneur principal avec Flexbox */
.container {
    display: flex;
    height: 100vh;
}

/* Panneaux latéraux */
.panel {
    padding: 20px;
    background-color: #2a2a2a;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease-in-out;
    min-width: 200px; /* Set a minimum width */
    flex-shrink: 0; /* Prevent panels from shrinking automatically */
}

.left-panel {
    --left-panel-width: 25%;
    flex-basis: var(--left-panel-width);
    border-right: 1px solid #333;
}

.right-panel {
    --right-panel-width: 25%;
    flex-basis: var(--right-panel-width);
    border-left: 1px solid #333;
}

.left-panel.chat-hidden,
.right-panel.video-hidden {
    flex-basis: 0 !important; /* Use important to override inline styles */
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border: none;
}

.panel h2 {
    margin-top: 0;
    margin-bottom: 0;
    color: #ffffff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* --- Panel Toggle Buttons --- */
#toggle-chat-btn, #toggle-video-panel-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background: #3a3a3a; /* Lighter than panel background */
    color: #eee;
    border: 1px solid #444;
    border-radius: 0 4px 4px 0;
    width: 24px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#toggle-chat-btn .icon, #toggle-video-panel-btn .icon {
    transition: transform 0.3s ease-in-out;
}

.material-symbols-outlined {
  font-size: 24px;
  vertical-align: middle;
  /* Do not selectable */
  user-select: none;
    font-variation-settings:
  'FILL' 0,
  'wght' 300,
  'GRAD' 0,
  'opsz' 24
}

#toggle-chat-btn.collapsed .icon, #toggle-video-panel-btn.collapsed .icon {
    transform: rotate(180deg);
}

#toggle-chat-btn {
    left: calc(var(--left-panel-width, 25%) - 20px);
    border-left: none;
}

.left-panel.chat-hidden ~ #toggle-chat-btn {
    left: 0;
}

#toggle-video-panel-btn {
    right: calc(var(--right-panel-width, 25%) - 20px);
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.right-panel.video-hidden ~ #toggle-video-panel-btn {
    right: 0;
}

#toggle-chat-btn:hover, #toggle-video-panel-btn:hover {
    background: #3a3a3a;
}


/* Contenu principal */
.main-content {
    flex-grow: 1; /* Allow it to take up the remaining space */
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px; /* Replaces justify-content for consistent spacing */
    background-color: #1e1e1e;
    min-width: 0; /* Prevent content from pushing layout */
}

.main-display {
    width: 100%;
    flex-grow: 1; /* Allow this area to grow and fill space */
    display: flex; /* Use flex to make child iframe fill it */
    min-height: 0; /* Prevents flex items from overflowing their container */
}

/* Tabbed Content */
.tab-content {
    width: 100%;
    flex-grow: 1;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 15px;
    min-height: 0;
}

#pj-content {
    /* This is a flex container for its children */
}

#sheet-display-area {
    flex-grow: 1; /* The iframe container should take all available space */
    display: flex;
}

/* Menu de navigation */
.main-menu {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 80%;
    padding: 8px 0;
    background-color: #2c2c2c;
    border-radius: 10px;
    border: 1px solid #3a3a3a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.menu-item {
    color: #e0e0e0;
    text-decoration: none;
    padding: 8px; /* Adjusted padding for icons */
    border: none;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item .material-symbols-outlined {
    font-size: 28px; /* Larger icons for main navigation */
}

.menu-item:hover, .menu-item.active {
    background-color: #4a4a4a;
    color: #ffffff;
}

.whiteboard-controls {
    padding: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #2c2c2c;
    border-bottom: 1px solid #3a3a3a;
    flex-shrink: 0;
}

#fabric-toolbar {
    display: flex;
    gap: 5px;
}

#fabric-toolbar .control-btn {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #333;
    border: 1px solid #444;
}

#fabric-toolbar .control-btn.active,
#fabric-toolbar .control-btn:hover {
    background-color: #444;
    border-color: #555;
}

#fabric-toolbar .control-btn .material-symbols-outlined {
    font-size: 20px;
    color: #eee;
}

#fabric-content .canvas-container {
    flex-grow: 1;
    width: 100%;
    height: 100%;
}

#fabric-color-picker {
    padding: 0;
    width: 36px;
    height: 36px;
}

/* --- Shared Controls Bar (for Sheets & Images) --- */
.sheets-controls, .image-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3a3a3a;
    flex-shrink: 0; /* Prevent the bar from shrinking */
}

.image-controls.hidden {
    display: none;
}

.sheets-controls select, .image-controls select {
    background-color: #3e3e3e;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 14px;
    flex-grow: 1;
}

.sheets-controls select:hover, .image-controls select:hover {
    background-color: #4a4a4a;
}

/* --- Shared Control Button Styles --- */
.control-btn {
    color: white;
    border: none;
    border-radius: 5px;
    width: 32px; /* Standardized size */
    height: 32px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0; /* Prevent buttons from shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:active {
    transform: scale(0.9);
}

.btn-add {
    background-color: #4CAF50;
}
.btn-add:hover {
    background-color: #45a049;
}

.btn-play {
    background-color: #4CAF50;
}
.btn-play:hover {
    background-color: #45a049;
}

.btn-delete {
    background-color: #f44336;
}
.btn-delete:hover {
    background-color: #d32f2f;
}

.btn-show {
    background-color: #2196F3; /* Blue for show */
}
.btn-show:hover {
    background-color: #1e88e5;
}

/* --- Styles pour le panneau de Chat --- */
.left-panel {
    height: 100vh;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background-color: #1e1e1e;
    border-radius: 5px;
    margin-bottom: 15px;
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: #2c2c2c;
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    font-size: 14px;
    word-wrap: break-word;
}

.chat-input-area {
    display: flex;
    margin-bottom: 15px;
}

#chat-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px 0 0 4px;
    background-color: #333;
    color: #f0f0f0;
    font-size: 14px;
}

#send-button {
    padding: 10px 15px;
    border: none;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    font-size: 14px;
}

#send-button:hover {
    background-color: #45a049;
}

.dice-roller {
    text-align: center;
}

.dice-roller h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #bbb;
}

.dice-roller .dice-button {
    width: 45px;
    height: 45px;
    margin: 5px;
    border: 2px solid #555;
    background-color: #fefefe;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    border-radius: 5px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    transition: all 0.1s ease-in-out;
}

.dice-roller .dice-button:active {
    transform: translateY(2px) translateX(1px);
    box-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

/* Styles for critical dice rolls */
.crit-success {
    color: #4CAF50;
    font-weight: bold;
}

.crit-fail {
    color: #f44336;
    font-weight: bold;
}

.game-roll-message {
    background-color: #ffffe0; /* lightyellow */
    color: #000000;
    border-left-color: #fbc02d; /* A darker yellow/gold for the border */
}

/* --- Styles pour le panneau Vidéo --- */
#video-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    overflow-y: auto;
}

.video-container {
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.video-container video {
    width: 100%;
    display: block;
}

.video-container .name-tag {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 13px;
    z-index: 2;
}

#global-controls {
    display: flex;
    gap: 8px;
}

#global-controls button {
    width: 32px;
    height: 32px;
    border-radius: 6px; /* Slightly rounded corners */
    border: 1px solid #555;
    font-size: 18px;
    cursor: pointer;
    background-color: transparent;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

#global-controls button.muted {
    background-color: #f44336; /* Red */
}

.unmute-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 3;
}

/* --- Image Management --- */
#carte-content {
    /* This is already a flex container from .tab-content */
    padding: 1rem;
    position: relative; /* For positioning the controls */
    gap: 1rem; /* Add some space between elements if needed */
}

#image-display-area {
    width: 100%;
    flex-grow: 1; /* This is the key change to make it fill available space */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px dashed #444;
    border-radius: 8px;
    background-color: #2b2b2b;
    color: #ccc;
    overflow: hidden; /* Ensures the image stays within the container */
}

#image-display-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Scales the image nicely */
}

/* Styles for the image controls are now handled by the shared .image-controls class */

/* --- FOG OF WAR CONTROLS --- */
#fabric-fog-toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background-color: #555;
    margin: 0 5px;
}

.brush-size-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 14px;
}

#fabric-fog-brush-size {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 8px;
    background: #444;
    outline: none;
    border-radius: 4px;
    transition: opacity .2s;
}

#fabric-fog-brush-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4CAF50;
    cursor: pointer;
    border-radius: 50%;
}

#fabric-fog-brush-size::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4CAF50;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.hidden {
    display: none !important;
}

/* --- Resizer Styles --- */
.resizer {
    background: #444;
    cursor: col-resize;
    flex-shrink: 0;
    width: 5px;
    z-index: 99;
    transition: background-color 0.2s;
}

.resizer:hover {
    background: #555;
}

/* Music Tab Styles */
.music-controls {
    padding: 10px;
    background-color: #2c2c2c;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.music-controls.hidden {
    display: none;
}

#youtube-url-input {
    flex-grow: 1;
    min-width: 200px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

#music-title {
    width: 100%;
    text-align: center;
    padding: 5px 0;
    color: #ccc;
    font-style: italic;
}

/* Hide the actual YouTube player iframe */
#youtube-player {
    width: 0;
    height: 0;
    overflow: hidden;
}

/* New Music Player Styles */
.music-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    height: 100%;
}

.music-container.hidden {
    display: none !important;
}

#music-main-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #2c2c2c;
    border-radius: 8px;
}

#music-current-track {
    flex-grow: 1;
    text-align: center;
    font-style: italic;
    color: #ccc;
}

#music-main-controls .main-buttons {
    display: flex;
    gap: 10px;
}

#music-main-controls .volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

#music-add-section {
    display: flex;
    gap: 10px;
}

#music-add-section input {
    flex-grow: 1;
    background-color: #333;
    border: 1px solid #444;
    color: #f0f0f0;
    padding: 8px;
    border-radius: 5px;
}

#music-playlist-options {
    display: flex;
    justify-content: flex-end;
}

.loop-control {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

#music-playlist {
    flex-grow: 1;
    overflow-y: auto;
    background-color: #252525;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.playlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background-color: #3a3a3a;
    border-radius: 5px;
    cursor: grab;
    border-left: 4px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.playlist-item:hover {
    background-color: #4a4a4a;
}

.playlist-item.playing {
    border-left-color: #4CAF50;
    font-weight: bold;
}

.playlist-item.dragging {
    opacity: 0.5;
    background: #555;
}

.playlist-item-title {
    flex-grow: 1;
}

.playlist-item-controls {
    display: flex;
    gap: 8px;
}
