:root{
	/* Scrollbars */
	--scrollbar-color : #999;
	--scrollbar-background-color : var(#fff);
	--scrollbar-width : thin;
    /* Enregistrement des variables de couleur */
	--rouge : #f44336;
	--winphone-rouge : #e51400;
	--rouge-win: #e51400;
	--vert : #4CAF50;
	--vert-clair: #bbffbb;
	--vert-khaki: #f0e68c;
	--khaki: #f0e68c;
	--bleu : #2196F3;
	--bleu-fonce: #1976D2;
	--bleu-tres-fonce: #3f51b5;
	--indigo: #3f51b5;
	--cobalt: #0050ef;
	--jaune: #ffeb3b;
	--orange: #ff9800;
	--orange-vif: #ff5722;
	--violet: #9c27b0;
	--rose : #ff1493;
	--marron:#795548;
	--gris-clair: #f1f1f1;
	--gris: #939393;
	--gris-fonce: #607d8b;
	--noir: #000000;
	--noir-clair: #111111;
	--blanc: #ffffff;
	--blanc-casse: #fafafa;
	--rouge-pale : #ffdddd;
	--jaune-pale : #ffffcc;
	--vert-pale : #ddffdd;
	--bleu-pale : #ddffff;
	--blert : #10edaf;
}


div{
	background-color: inherit;
}
/* Scrollbars for Blink */
::-webkit-scrollbar {
	width: 12px;
}
/* Track */
::-webkit-scrollbar-track {
	box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
	/*border-radius: 10px;*/
	background: var(--scrollbar-background-color);
}
/* Handle */
::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: var(--scrollbar-color);
	-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
	background: var(--scrollbar-background-color);
}


/* Styles de base */
* {
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}
body {
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
    overflow: auto;
}

#app-container {
    position: absolute;
    top:0;
    left:0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    /* pour la barre de menus en haut */
	--top-bar-height : 3em;
	padding-top: calc( var(--top-bar-height) + 0px );
}

.top-bar-menu:not(.visible),
.w3-modal:not(.visible),
.tab-container:not(.visible) {
    display: none !important;
}

.top-bar-menu.visible,
.w3-modal.visible,
.tab-container.visible {
    display: block !important;
}


#bd-images-panel-wrapper{
	transition-property: right;
	transition-duration: 0.3s;
	position: fixed;
	right: -24.5em;
	top: calc( var(--top-bar-height) - 2px );
	height: calc( 100vh - var(--top-bar-height) + 2px );
	border: 1px solid black;
	width: 24em;
	background-color: #efefef;
	overflow-y: auto;
}

.bd-images-panel-group-content{
	height: calc( 100vh - var(--top-bar-height) - 3em - 2px );
	user-select: none;
}

#bd-images-panel-opener::before{
	content: "Ajouter";
}
body.open-image-bank #bd-images-panel-opener::before{
	content: "Fermer";
}



.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Barre d'outils */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.toolbar button {
    padding: 8px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.toolbar button:hover {
    background-color: #45a049;
}
.toolbar button:active {
    background-color: #3e8e41;
}
.toolbar select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Zone de la bande dessinée */
.comic-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
    align-items: center;
}
.comic-page {
    width: 800px;
    height: 1100px; /* Format A4 approximatif */
    background-color: white;
    border: 1px solid #ccc;
    position: relative;
    /* On centre avec flex : align-items:center pour éviter des erreurs de domToImg */
    margin: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Cadres */
.frame {
    border: 2px solid #333;
    position: absolute;
    background-color: white;
    overflow: hidden;
    cursor: move;
    z-index: 0;
}
.frame.selected {
    border: 2px dashed #ff4500;
    z-index: 10;
}
.frame::before{
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    background-color: rgba(150, 150, 150, 0.7);
    z-index: 100;
    transition: top 0.2s ease-in-out;
}
/*.frame:hover::before{
    top: 0px;
}*/


.frame-handle {
    --width: 20px;
    width: var(--width);
    height: var(--width);
    background-color: #fff;
    border: 1px solid #333;
    position: absolute;
    top: 0;
    right: calc( -1px - var(--width) );
    cursor: pointer;
    z-index: 1000;
    transition: right 0.3s ease-in-out;
}
.frame:hover .frame-handle {
    right: 0;
}
.clone .frame-handle{
    display: none;
}

/* Elements dans le cadre */
.character, .background, .speech-bubble {
    position: absolute;
    cursor: move;
    z-index: 50;
}
.character.selected, .background.selected, .speech-bubble.selected {
    outline: 2px dashed #4286f4;
}

/* Bulles de dialogue */
.speech-bubble {
    background-color: white;
    border: 2px solid black;
    border-radius: 20px;
    padding: 10px;
    min-width: 80px;
    min-height: 40px;
}
.speech-bubble:before {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 20px;
    border: 10px solid transparent;
    border-top-color: black;
}
.speech-bubble textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-family: 'Comic Sans MS', cursive;
    padding: 5px;
}



#selection-box {
	position: absolute;
	border: 2px solid red;
	pointer-events: auto;
	box-sizing: border-box;
	transform-origin: center;
	background: none !important;
	z-index: 1000;
}

.resize-handle {
	position: absolute;
	width: 10px;
	height: 10px;
	background-color: red;
	border: 1px solid white;
}

.rotate-handle {
	position: absolute;
	width: 15px;
	height: 15px;
	background-color: green;
	border-radius: 50%;
	cursor: pointer;
}


/* Panneau latéral */
.sidebar {
    position: fixed;
    right: 20px;
    top: 20px;
    width: 250px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 15px;
}
.sidebar h3 {
    margin-top: 0;
}
.image-library {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.image-library img {
    width: 100%;
    height: auto;
    cursor: pointer;
    border: 1px solid #ddd;
}
.upload-section {
    margin-top: 15px;
}

/* Styles pour les boutons de pages */
.page-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* Prévisualisation des pages */
#page-thumbnails {
	display: flex;
	flex-direction: column;
	position: fixed;
	left: calc( -140px + 3em );
	top: 6em;
	transition: left 0.2s ease-in-out;
	padding: 20px;
}
#page-thumbnails:hover {
	left: 0;
}
.page-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    margin-bottom: 15px;
}
.page-thumbnail {
    width: 100px;
    height: 140px;
    border: 1px solid #ddd;
    cursor: pointer;
    background-color: white;
}
.page-thumbnail.active {
    border: 2px solid #4CAF50;
}

/* Resize éléments*/
.resize-box {
    position: absolute;
    border: 2px solid blue;
    display: none;
    pointer-events: none;
}

.resize-box-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: red;
    pointer-events: all;
}

.resize-ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-e { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.resize-w { left: -5px; top: 50%; transform: translateY(-50%); cursor: w-resize; }


/* Popup */
.center-panel-background {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(50, 50, 50, 0.85);
    justify-content: center;
    align-items: center;
}
.center-panel {
	position: absolute;
	top: 50%;
	left: 50%;
	min-width: 40vw;
	max-width: 90vw;
	transform: translate(-50%, -50%);
	background: rgba(225, 225, 225, 0.9);
	padding: 20px;
	border-radius: 10px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    text-align: center;
}
.close-panel-button {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 20px;
    background-color: #ff4500;
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.close-panel-button::before {
    display: block;
}

.hidden {
    transition-property: opacity;
    transition-duration: 0.5s;
    opacity: 0;
}
.visible {
    transition-property: opacity;
    transition-duration: 0.5s;
    opacity: 1;
    z-index: 500;
}

@media (max-width: 500px) {
    .center-panel{
        min-width:  90vw;
    }
}
@media (max-height: 500px) {
    .center-panel{
        max-height:  70vw;
    }
}




/* Écrans petits */
@media (max-width: 800px){
	#bd-images-panel-wrapper{
		right: unset !important;
		top: unset !important;
		left: 0;
		bottom: 0;
		width: 100%;
		max-height: 35vh;
		bottom: -36vh;
		border-width: 1px 0;
		opacity: 0;
		transition: all ease 0.5s;
	}
	body.open-image-bank #bd-images-panel-wrapper{
		bottom: 0;
		opacity: 1;
	}
	#bd-images-panel-opener{
		position: fixed;
		left: 10px;
		bottom: 10px;
		border: 1px solid black;
		transition: all ease 0.5s;
		z-index: 2;
	}
	body.open-image-bank #bd-images-panel-opener{
		left: 0;
		bottom: 35vh;
	}
	.bd-image-group .bd-image-group-title{
		display:none;
	}
	body div.bd-image-group{
		min-height: 0 !important;
		max-height: 0;
		padding:0;
		margin: 0;
	}
	.l-only{
		display:none !important;
	}
	.bd-images-panel-group-content{
		max-height: calc( 35vh + 18em );
		max-height: calc(35vh - 3.5em) !important;
	}
	.w3-modal{
		/* fix temporaire pour les smartphones */
		padding-top: 8em !important;
	}
	#floating-preview {
		bottom : 3em;
		right : 1em;
	}
	#floating-preview-button-bar{
		bottom: -2.5em;
		font-size:1em;
	}
	#floating-preview-button-bar{
		bottom: -2.5em;
		font-size:1em;
	}
	#floating-preview-button-bar button{
		margin-left: -0.8em;
	}
	.save-load-element{
		display: block !important;
	}
	
	#canvas-project-settings-commands>* {
		text-align: center;
		overflow: hidden !important;
	}
	#canvas-project-settings-commands {
		position: fixed;
		bottom: 0;
		top: unset;
		right: 0;
		width : 100vw;
		display: grid;
		/*grid-template-areas: "add-line rwidth delete-cell" "add-col rheight select-parent" "reset-proto reset-proto reset-proto";*/
		grid-template-areas:
			"project-settings-commands-add-line project-settings-commands-rsizes project-settings-commands-delete-cell"
			"project-settings-commands-add-col project-settings-commands-rsizes project-settings-commands-select-parent"
			"project-settings-commands-return-button project-settings-commands-reset-proto project-settings-commands-validate";
	}
	#canvas-load-project-modal #canvas-projects-new-settings-validate{
		grid-area: project-settings-commands-validate;
	}
	#canvas-load-project-modal #canvas-projects-new-settings-cancel{
		grid-area: project-settings-commands-return-button;
	}
	#canvas-project-settings-commands-add-line{
		grid-area: project-settings-commands-add-line;
	}
	#canvas-project-settings-commands-add-column{
		grid-area: project-settings-commands-add-col;
	}
	#canvas-project-settings-commands-label-rwidth{
		grid-area: project-settings-commands-rwidth;
	}
	#canvas-project-settings-commands-label-rheight{
		grid-area: project-settings-commands-rheight;
	}
	#canvas-project-settings-commands-label-rsizes{
		grid-area: project-settings-commands-rsizes;
	}
	#canvas-project-settings-commands-select-container{
		grid-area: project-settings-commands-select-parent;
	}
	#canvas-project-settings-commands-delete{
		grid-area: project-settings-commands-delete-cell;
	}
	#canvas-project-settings-commands-reset{
		grid-area: project-settings-commands-reset-proto;
	}
}
/* Écrans larges */
@media (min-width: 800px){
	body.open-image-bank #bd-canvas-wrapper {
		/* La taille du panneau de droite */
		padding-right: 20em;
	}
	body.open-image-bank #bd-images-panel-wrapper {
		right: -1px;
	}
	#floating-preview {
		transform: scale(1.5);
		transform-origin: 90% 100%;
	}
	.s-only {
		display:none !important;
	}
	body.open-image-bank #floating-preview{
		right: 25em;
	}
	/*
	#canvas-project-settings-commands>* {
		display: block;
		padding: 0.25em 0.5em;
	}
	*/
}
