:root { --accent: #800000; --dark: #1a1a1a; }
body, html { margin: 0; height: 100%; overflow: hidden; font-family: sans-serif; background: #eee; }
/* WebKit browsers */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: #f0f0f0;
}
::-webkit-scrollbar-thumb {
    background-color: #800000;
    border-radius: 10px;
    border: 3px solid #f0f0f0;
	background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #a00000;
}

/* Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: #800000 #f0f0f0;
}
/* 1. APP STRUCTURE: VERTICAL STACK ONLY */
#designer-app { 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    position: relative; 
}

/* 2. TOOLBAR: ALWAYS AT THE VERY BOTTOM */
#main-toolbar { 
    position: fixed; 
    bottom: 0px; /* Exactly the height of the footer */
    left: 0; 
    width: 100%; 
    height: 65px; /* Slightly taller for easier clicking */
    background: var(--dark); 
    display: flex; 
    flex-direction: row; 
    justify-content: space-around; 
    align-items: center; 
    z-index: 3100; /* Sits above footer */
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.tool-btn { background: none; border: none; color: white; cursor: pointer; display: flex; flex-direction: column; align-items: center; font-size: 10px; }
.tool-btn i { font-size: 20px; font-style: normal; border: 1px solid #444; width: 35px; height: 35px; line-height: 35px; border-radius: 5px; margin-bottom: 2px; }

/* 4. WORKSPACE: THE TOP SECTION */
#topbox{ position: relative; background-color:#E1E1E1; display: flex; justify-content: center; flex-direction: column; align-items: center; height:100px; }
#text_wrapper {
	position: absolute;
	background-color:#E1E1E1;
    overflow: visible;        /* clips scrollbar edges */
    width: 100%;
	top: 0px;        /* right below the size row */
    left: 50%;
   box-sizing: border-box;
	 margin: 0 auto;
    z-index: 3200 !important;
    
    transform-origin: top;   /* slide from top */
    transform: translateX(-50%) scaleY(0);    /* collapsed */
    transition: transform 0.4s ease;
}

#text_wrapper.open {
    transform: translateX(-50%) scaleY(1);    /* expanded */
}

#workspace {
    display: flex;
	flex-direction: column;
    align-items: center;
    justify-content: center;
}
#canvas-wrapper { width: 100%; display: flex; justify-content: center; }
#mainCanvas { 
    max-width: 95vw; 
    max-height: 60vh; /* Keeps room for the drawers below */
    object-fit: contain; 
    box-shadow: 0 0 20px rgba(0,0,0,0.2); 
    background: #000; 
}
#cart_info{ position: relative; background-color:#E1E1E1; display: flex; justify-content: center; flex-direction: column; align-items: center; }
.finals{ color:#800000;font-size:16px; }
#canvas-div-wrapper { display: inline-flex; }
#select_colors_wrapper {
    position: absolute;
    border: 1px solid #800000;
    border-radius: 10px 10px 0 0;  /* rounded top corners instead of bottom */
    background-color: #fff;
    overflow: hidden;
    width: 200px;

    /* Position it at the bottom of the trigger row instead of top */
    bottom: 70px;  /* distance from the bottom of the trigger element */
    left: 50%;
    transform: translateX(-50%) scaleY(0); /* collapsed */
    transform-origin: bottom; /* animate from bottom up */
    transition: transform 0.4s ease;
    z-index: 3200 !important;
}

#select_colors_wrapper.open {
    transform: translateX(-50%) scaleY(1); /* expand upward */
}

/* Inner div handles horizontal scrolling */
#select_colors {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;        /* scroll inside wrapper */
    overflow-y: hidden;
    padding: 5px;
}
.color-thumb { font-size:16px; text-align:center; cursor:pointer; } 
.color-thumb img { width: 40px; height: 40px; border-radius: 5px; }

/* 5. UNIVERSAL BOTTOM DRAWERS */
.edit-interface, #side-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important; /* Fix: Changed from 115px to 0 */
    width: 100% !important;
    background: white !important;
    z-index: 5000; 
    transform: translateY(100%); /* Start at the very edge */
    transition: transform 0.3s ease-out;
    border-top: 3px solid var(--accent);
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
    display: none;
}
.edit-interface {
    z-index: 3200 !important; /* Must be HIGHER than #main-toolbar (3100) */
}
.edit-interface.active { 
    display: flex !important; 
    flex-direction: column;
    align-items: center; 
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Specific positioning for the Sliders (Bottom) Drawer */
#bottom-edit-bar {
    position: fixed !important;
    bottom: 0 !important; /* Force it to the bottom */
    left: 0 !important;
    right: 0 !important;
    height: 200px !important; /* Fixed height to cover footer/toolbar */
    background: white !important;
    z-index: 4500 !important; /* Above toolbar (3100) */
    display: none; /* Hidden until JS triggers flex */
    
    /* Animation */
    transform: translateY(100%); 
    transition: transform 0.3s ease-out;
    
    border-top: 3px solid var(--accent);
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
}

#bottom-edit-bar.active {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    transform: translateY(0) !important;
}

/* Positioning for the Input (Top) Drawer - Sits above the Sliders */
#top-edit-bar {
    display: flex;
    position: fixed;
	flex-direction: column;
    justify-content: center;
	align-items: center;
    gap: 8px;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: white;
    z-index: 5000; /* Highest priority */
    transform: translateY(-100%); /* Start off-screen top */
    transition: transform 0.3s ease-out;
    border-bottom: 3px solid var(--accent);
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#top-edit-bar.active {
    transform: translateY(0);
}

/* ACTIVE STATE */
.edit-interface.active, #side-panel.active { 
    transform: translateY(0) !important;
    display: block !important;
}

/* 6. DRAWER CONTENT STYLING */
.slider-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.slider-item {
    width: calc(100% - 20px);
    margin: 0 auto;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;

    max-height: 0;
    opacity: 0;
    overflow: hidden;

    transition: 
        max-height 0.35s ease,
        opacity 0.2s ease;
}

.slider-item.open {
    max-height: 60px; /* adjust if needed */
    opacity: 1;

    padding-bottom: 10px;
}

.slider-item label { min-width: 45px; font-size: 11px; font-weight: bold; }
.stepper-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.stepper-wrap input[type="range"] {
    flex: 1;
}

.step-btn {
    flex: 0 0 40px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: linear-gradient(to bottom, #ffffff, #eaeaea);
    cursor: pointer;
	font-size:26px;
}
/* COLOR SCROLLER */
.color-drawer-layout { display: flex; align-items: center; gap: 10px; }
.color-scroll-container { flex: 1; display: flex; gap: 10px; overflow-x: auto; padding: 5px 0; }

/* 7. HIDE DESKTOP-ONLY ARTIFACTS */
#side-panel .panel-header { background: var(--dark); color: white; margin: -15px -15px 10px -15px; padding: 10px; }

/* ADJUST THE TOP BAR INPUT ROW */
.input-row {
    display: flex;
    align-items: center;
	justify-content: center;
    width: 100%;
	gap: 0;
	box-sizing: border-box;
}
#textInput {
    flex: 1 1 60%;       /* grow, shrink, basis 60% */
    min-width: 0;        /* allows shrinking below 60% if needed */
    height: 30px;       /* same as button */
    padding: 0 10px;
    font-size: 16px;
    border: 2px solid #800000;
    border-right: none; /* visually merge with button */
    border-radius: 0px 0px 0px 10px;
    box-sizing: border-box;
}
.font-row, #font-picker-container {
    flex: 1 1 40%;       /* grow, shrink, basis 40% */
    display: flex;
    justify-content: flex-start; /* align dropdown content to the left of this container */
	min-width: 0;        /* prevents overflow on small screens */
    box-sizing: border-box;
}
#edit_text_row {
	display:flex;
	flex-direction: column;
	background-color:#800000;
    align-items: center;
	justify-content: center;
    width: calc(100% - 20px);
	color:#fff;
	border-radius: 0px 0px 10px 10px;
    margin: 0 auto;

}
/* CONSTRAIN THE FONT PICKER */
#font-picker-container {
    position: relative;   /* for dropdown positioning */
}

#current-font-display {
    display: flex;
    align-items: center;
    justify-content: space-between; /* text left, arrow right */
    height: 30px;                   /* match input height */
    padding: 0 12px;
    background: #800000;
    color: #fff;
    font-size: 16px;
    border: 2px solid #800000;
    border-radius: 0px 0px 10px 0px;
    cursor: pointer;
	width:100%;
    box-sizing: border-box;
    position: relative;
}
#current-font-display::after {
    content: '▼';
    margin-left: 8px;
    font-size: 12px;
}

#current-font-display:active {
    transform: scale(0.97);
}

#font-list-ul {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* matches button width automatically */
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    list-style: none;
    padding: 0;
    margin: 0;
    z-index: 4000;
    display: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
#font-list-ul.open {
    display: block !important;
}

#font-list-ul li {
    padding: 5px;
    border-bottom: 1px solid #eee;
    font-size: 16px; /* Larger for easy mobile tapping */
    cursor: pointer;
}

#font-list-ul li:hover {
    background: #f0f0f0;
}

.edit_buttons {
  background: linear-gradient(to bottom, #ffffff, #eaeaea);
  color: #800000;
  padding: 2px 5px;
  border-radius: 10px;
  border: 1px solid #d0d0d0;
  cursor: pointer;

  box-shadow: 
    0 4px 6px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.7);

  transition: all 0.2s ease;
}

.edit_buttons:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 12px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.8);
}

.edit_buttons.active {
  background: linear-gradient(to bottom, #d4af37, #b8962e);
  color: #2b2b2b;
  border: 1px solid #a8851f;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#saveOverlay {
    display: none; /* Hidden by default */
}