.app-container {
    display: flex;
    flex-direction: column;
}

/* ========================================
   CRITICAL: Make editor fit inside container
   ======================================== */

/* The about-section container wraps everything — 
   ensure no overflow escapes */
.about-section {
    overflow: hidden;
}

.about-section .container {
    overflow: hidden;
    padding-left: 12px;
    padding-right: 12px;
}

/* Toolbar Styles - Modern Layout */
.toolbar {
    display: flex;
    flex-wrap: wrap; /* Allows items to wrap to next line */
    align-items: center;
    padding: 3px 4px;
    gap: 6px;
  
    z-index: 1000;
    min-height: 32px;
    /* Prevent toolbar from exceeding its parent */
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0; /* allow shrinking */
}

.toolbar-break {
    flex-basis: 100%; /* Forces next item to new line */
    height: 0;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16px;
    font-weight: 700;
    color: #2563eb;
    padding-right: 2px;
}

.app-logo i {
    font-size: 22px;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8f8f8;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    background: #e0e0e0;
    margin: 0 4px;
    display: inline-block;
    flex-shrink: 0;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3px 3px;
    background: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #444;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.toolbar-btn:hover {
    background: #f8f8f8;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.toolbar-btn-primary {
    background: linear-gradient(to bottom, #2563eb, #1d4ed8);
    color: white;
    border-color: #1d4ed8;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.toolbar-btn-primary:hover {
    background: linear-gradient(to bottom, #1d4ed8, #1e40af);
    box-shadow: 0 3px 6px rgba(37, 99, 235, 0.4);
}

.toolbar-btn-icon {
    padding: 7px 10px;
    min-width: 36px;
}

.toolbar-btn.active {
    background: #2563eb;
    color: white;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.toolbar-select {
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-width: 120px;   /* slightly narrowed from 140px */
    max-width: 140px;
    transition: all 0.2s;
    flex-shrink: 1;
}

.toolbar-select-small {
    min-width: 60px;
    max-width: 70px;
    text-align: center;
}

.toolbar-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.toolbar-select:hover {
    border-color: #d0d0d0;
}

/* Font Size Control with +/- buttons */
.font-size-control {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: white;
    border: none;
    border-radius: 6px;
    padding: 2px;
    flex-shrink: 0;
}

.font-size-control .toolbar-btn {
    border: none;
    padding: 5px 8px;
    min-width: 28px;
    border-radius: 4px;
}

.font-size-control .toolbar-select {
    border: none;
    border-radius: 0;
  /*  border-left: 1px solid #e8e8e8;
    border-right: 1px solid #e8e8e8; */
    min-width: 56px;
    max-width: 64px;
    padding: 5px 8px;
}

.font-size-control .toolbar-select:focus {
    box-shadow: none;
}

.color-picker-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.color-picker-wrapper:hover {
    background: #f8f8f8;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.color-picker-wrapper i {
    pointer-events: none;
    font-size: 16px;
    color: #444;
}

/* Shape Fill Control */
.shape-fill-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #444;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.shape-fill-control:hover {
    background: #f8f8f8;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.shape-fill-control input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

.shape-fill-control span {
    user-select: none;
}

/* Shape Selector Panel — sits in normal flow directly below the toolbar */
.shape-selector-panel {
    position: relative;
    width: 100%;
    box-sizing: border-box;
   
    border-bottom: 2px solid #dbe4ff;
    border-top: 1px solid #e0e0e0;
    padding: 6px 12px;
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    z-index: 999;
    box-shadow: inset 0 2px 4px rgba(37, 99, 235, 0.04),
                0 3px 8px rgba(0, 0, 0, 0.07);
}

/* label prefix — shown via JS toggling display:flex */
.shape-selector-panel::before {
    /* content: "Insert shape:"; */
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
    white-space: nowrap;
    align-self: center;
}

.shape-option {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.shape-option:hover {
    background: #eef2ff;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

.shape-option i {
    font-size: 15px;
    color: #2563eb;
    flex-shrink: 0;
}

.shape-option span {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

/* ========================================
   MAIN LAYOUT — height is explicitly set so
   the slides panel has something to constrain to
   ======================================== */

.main-content {
    display: flex;
    flex: none;           /* do NOT flex-grow; height is explicit below */
    width: 100%;
    min-width: 0;
    overflow: hidden;
    /* Height = canvas height at max-width 960px (16:9 = 540px) + footer ~29px.
       We use a CSS custom property so it can be overridden by JS if needed.
       The key insight: without an explicit height here, .slides-panel has
       nothing to be constrained against. */
    height: calc(min(100vw - 212px, 960px) * 9 / 16 + 29px);
    min-height: 320px;
    max-height: 600px;
}

/* ========================================
   SLIDES PANEL — strictly constrained to
   .main-content height, scrolls inside
   ======================================== */

.slides-panel {
    width: 200px;
    min-width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    /* height is inherited from .main-content via align-self:stretch */
    height: 100%;
    overflow: hidden;     /* clip anything that tries to escape */
}

.slides-panel-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    flex-shrink: 0;       /* header never squishes */
}

.slides-panel-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-slide-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: linear-gradient(to bottom, #2563eb, #1d4ed8);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.add-slide-btn:hover {
    background: linear-gradient(to bottom, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

/* ========================================
   SLIDES LIST — scrollable region.
   flex:1 + min-height:0 fills remaining
   panel height and scrolls within it.
   ======================================== */
.slides-list {
    flex: 1;
    min-height: 0;        /* CRITICAL: lets flex child shrink below content size */
    overflow-y: auto;     /* vertical scrollbar when thumbnails overflow */
    overflow-x: hidden;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    background: #E8E8E8; 
}

/* Webkit scrollbar for slides-list */
.slides-list::-webkit-scrollbar {
    width: 6px;
}


.slides-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.slides-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.slide-thumb {
    position: relative;
    background: white;
    border: 2px solid transparent;
    border-color: #EEEEEE;
    border-radius: 2px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.slide-thumb:hover {
    border-color: #2563eb;
    transform: translateX(1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.slide-thumb.active {
    border-color: red;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
}

.slide-thumb-preview {
    aspect-ratio: 16/9;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.slide-thumb-canvas {
    position: relative;
    transform-origin: top left;
}

.slide-thumb-element {
    line-height: 1.2;
}

.slide-thumb-element ul,
.slide-thumb-element ol {
    margin: 0;
    padding-left: 12px;
    list-style-position: outside;
}

.slide-thumb-element ul {
    list-style-type: disc;
}

.slide-thumb-element ol {
    list-style-type: decimal;
}

.slide-thumb-element li {
    margin: 0;
    font-size: inherit;
    padding-left: 2px;
}

.slide-thumb-number {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(122, 122, 122, 0.5);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.slide-thumb-delete {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: transparent;
    color: gray;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.slide-thumb-delete:hover {
    background: transparent;
    color: red;
}


/* ========================================
   EDITOR AREA — fills remaining space,
   canvas scales to fit exactly
   ======================================== */

.editor-area {
    flex: 1;
    min-width: 0;   /* critical: allow flex child to shrink */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #e8e8e8 0%, #f0f0f0 100%);
    overflow: hidden;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow: auto;
    min-height: 0;
    min-width: 0;
    box-sizing: border-box;
}

/* Webkit scrollbar for editor-wrapper */
.editor-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.editor-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.editor-wrapper::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.editor-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ========================================
   SLIDE CANVAS — true 16:9, fills width,
   height always driven by aspect-ratio.
   ======================================== */
.slide-canvas {
    width: 100%;
    max-width: 960px;
    height: auto;
    aspect-ratio: 16 / 9;
    background: white;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    flex-shrink: 0;
}

.editor-footer {
    padding: 5px 10px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}


/* Slide Elements */
.slide-element {
    position: absolute;
    cursor: move;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.slide-element.selected {
    border: 2px solid #2563eb;
}

.slide-element.selected .resize-handle {
    display: block;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid #2563eb;
    border-radius: 50%;
    display: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.n  { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.e  { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.resize-handle.w  { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }

.text-element {
    min-width: 100px;
    min-height: 40px;
}

.text-element [contenteditable] {
    outline: none;
    width: 100%;
    height: 100%;
    padding: 12px 12px 12px 20px;
    box-sizing: border-box;
}

.text-element [contenteditable] ul,
.text-element [contenteditable] ol {
    margin: 0;
    padding-left: 30px;
    list-style-position: outside;
}

.text-element [contenteditable] ul { list-style-type: disc; }
.text-element [contenteditable] ol { list-style-type: decimal; }

.text-element [contenteditable] li {
    margin: 4px 0;
    padding-left: 5px;
}

.text-element [contenteditable]:empty:before {
    content: "Click to add text";
    color: #a0a0a0;
    font-style: italic;
}

.text-element [contenteditable="true"] {
    outline: none;
    background: transparent;
    cursor: text;
}

.text-element [contenteditable="false"] { cursor: move; }
.text-element [contenteditable="false"]:hover { cursor: move; }
.text-element:hover [contenteditable="false"] { background: rgba(0, 0, 0, 0.02); }

.image-element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.shape-element {
    width: 100%;
    height: 100%;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 180px;
    padding: 6px;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
    border-radius: 6px;
}

.context-menu-item:hover {
    background: #f8f8f8;
    color: #2563eb;
}

.context-menu-item i { width: 18px; color: #666; }
.context-menu-item:hover i { color: #2563eb; }

/* ========================================
   MODALS
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.modal-body {
    padding: 28px;
    overflow-y: auto;
    flex: 1;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.template-card {
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.template-card:hover {
    border-color: #2563eb;
    box-shadow: 0 6px 10px rgba(37, 99, 235, 0.2);
    transform: translateY(-4px);
}

.template-preview {
    aspect-ratio: 16/9;
    background: #f9fafb;
    padding: 7px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.template-title {
    font-size: 16px;
    font-weight: bold;
    color: #1f2937;
    text-align: center;
    margin-bottom: 8px;
}

.template-subtitle {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

.template-title-small {
    font-size: 11px;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #e5e7eb;
}

.template-bullets {
    font-size: 9px;
    color: #6b7280;
    line-height: 1.8;
}

.template-two-col {
    display: flex;
    gap: 8px;
    font-size: 9px;
    color: #6b7280;
}

.template-col {
    flex: 1;
    line-height: 1.8;
}

.template-section-title {
    font-size: 18px;
    font-weight: bold;
    color: #2563eb;
    text-align: center;
}

.template-image-placeholder {
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.template-image-placeholder i {
    font-size: 22px;
    color: #9ca3af;
}

.template-blank {
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-blank-text {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}

.template-name {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: white;
    border-top: 1px solid #e5e7eb;
}

/* Load Presentations Modal */
.presentations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.presentation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s;
}

.presentation-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.presentation-info { flex: 1; }

.presentation-name {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.presentation-date {
    font-size: 12px;
    color: #6b7280;
}

.load-btn {
    padding: 8px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.load-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.load-btn:active { transform: translateY(0); }

.no-presentations {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
    font-style: italic;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Large screens: hide text labels from toolbar buttons */
@media (max-width: 1024px) {
    .toolbar-btn span { display: none; }
    .slides-panel { width: 175px; }
}

/* Tablet */
@media (max-width: 900px) {
    .slides-panel { width: 150px; min-width: 130px; }

    .toolbar-select { min-width: 95px; }

    .modal-content { width: 95%; max-height: 90vh; border-radius: 8px; }
    .modal-header { padding: 16px 20px; }
    .modal-header h2 { font-size: 18px; }
    .modal-body { padding: 16px; }
    .template-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
}

/* Small tablet / large phone landscape */
@media (max-width: 768px) {
    .toolbar { flex-wrap: wrap; padding: 6px; }
    .toolbar-main { width: 100%; }

    .slides-panel { width: 120px; min-width: 100px; }

    .editor-wrapper { padding: 8px; }

    .slide-thumb { margin-bottom: 8px; }
}

/* Phone landscape / small tablet portrait */
@media (max-width: 640px) {
    /* Stack slides panel on top */
    .main-content {
        flex-direction: column;
        height: auto;
    }

    .slides-panel {
        width: 100%;
        height: 110px;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        flex-direction: row;
        /* Override vertical scroll for horizontal layout */
        overflow: hidden;
    }

    .slides-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;     /* horizontal scroll on mobile */
        overflow-y: hidden;
        padding: 8px;
        gap: 8px;
    }

    .slide-thumb {
        flex-shrink: 0;
        width: 140px;
        margin-bottom: 0;
    }

    /* Canvas fills full width on small screens */
    .slide-canvas {
        width: 100% !important;
        max-width: 100% !important;
    }

    .editor-area { min-height: 260px; }
    .editor-wrapper { padding: 8px; }
    .editor-footer { padding: 6px; }

    /* Toolbar tweaks */
    .toolbar { gap: 3px; padding: 5px; }
    .toolbar-divider { display: none; }
    .font-size-control { gap: 1px; }
    .toolbar-select { min-width: 85px; font-size: 12px; padding: 5px 6px; }

    /* Shape panel */
    .shape-selector-panel { padding: 5px 8px; gap: 5px; }
    .shape-option { padding: 4px 8px; }
    .shape-option i { font-size: 13px; }
    .shape-option span { font-size: 11px; }
    .shape-selector-panel::before { font-size: 10px; }

    /* Modal */
    .modal-content { width: 98%; }
    .template-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* Very small phones */
@media (max-width: 400px) {
    .template-grid { grid-template-columns: 1fr; }
    .toolbar-btn-icon { min-width: 30px; padding: 6px 7px; }
}

/* Add to your existing CSS */
#slideCanvas {
    transform-origin: top left;
    transition: transform 0.2s ease;
}

.canvas-container {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
}

.canvas-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.canvas-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.canvas-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.canvas-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#slideCanvas {
    transform-origin: top left;
    transition: transform 0.2s ease;
}

/* Project Name Modal Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(to bottom, #2563eb, #1d4ed8);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    font-weight: 600;
    color: #2563eb;
}

/* Success/Error Messages */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.status-success {
    background: linear-gradient(to right, #10b981, #059669);
    color: white;
    border-left: 4px solid #047857;
}

.status-error {
    background: linear-gradient(to right, #ef4444, #dc2626);
    color: white;
    border-left: 4px solid #b91c1c;
}

.status-warning {
    background: linear-gradient(to right, #f59e0b, #d97706);
    color: white;
    border-left: 4px solid #b45309;
}

/* Responsive styles for modals */
@media (max-width: 640px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* Improve form controls on mobile */
@media (max-width: 480px) {
    .form-control {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .loading-spinner {
        transform: scale(0.8);
    }
    
    .status-message {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
}


/* Unsaved Changes Modal Styles */
.warning-icon {
    text-align: center;
    margin-bottom: 20px;
}

.warning-icon i {
    font-size: 48px;
    color: #f59e0b;
}

.warning-text {
    text-align: center;
    font-size: 16px;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Loading overlay for page reload */
.page-reload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    backdrop-filter: blur(3px);
}

.page-reload-overlay .loading-spinner {
    text-align: center;
}

.page-reload-overlay .spinner {
    width: 80px;
    height: 80px;
    border: 5px solid rgba(37, 99, 235, 0.1);
    border-top-color: #2563eb;
}

.page-reload-overlay .loading-text {
    font-size: 18px;
    font-weight: 600;
    margin-top: 20px;
}

/* Export Overlay Styles */
.export-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.export-overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(37, 99, 235, 0.1);
}

.export-spinner-container {
    position: relative;
    width: 80px;
    height: 80px;
}

.export-spinner {
    width: 80px;
    height: 80px;
    border: 6px solid rgba(37, 99, 235, 0.1);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.export-spinner-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border: 6px solid transparent;
    border-top-color: rgba(37, 99, 235, 0.3);
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
}

.export-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.export-message {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 10px;
}

.export-progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.export-progress-bar {
    flex: 1;
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.export-progress-bar .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.export-progress {
    font-size: 14px;
    font-weight: 600;
    color: #2563eb;
    min-width: 40px;
    opacity: 0.8;
    transition: opacity 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Export Warning Modal Styles */
.warning-subtext {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 10px;
    line-height: 1.4;
}

.warning-icon i {
    font-size: 48px;
    color: #f59e0b;
}

.bi-exclamation-circle {
    color: #f59e0b;
}

/* Redirecting State */
.redirecting .spinner {
    border-top-color: #10b981;
    animation: pulseSpin 1.5s ease-in-out infinite;
}

.redirecting .loading-text {
    color: #10b981;
    font-weight: 700;
}

@keyframes pulseSpin {
    0% { transform: rotate(0deg); border-width: 4px; }
    50% { transform: rotate(180deg); border-width: 6px; }
    100% { transform: rotate(360deg); border-width: 4px; }
}

.redirecting::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(16, 185, 129, 0.05) 0%, 
        rgba(255, 255, 255, 0.9) 50%, 
        rgba(37, 99, 235, 0.05) 100%);
    z-index: -1;
}

/* Redirecting State for Loading Overlay */
.loading-overlay.redirecting {
    background: rgba(255, 255, 255, 0.95);
}

.loading-overlay.redirecting .spinner {
    border-top-color: #10b981;
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-overlay.redirecting .loading-text {
    color: #10b981;
    font-weight: 600;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Color picker immediate feedback */
#slideBackground {
    transition: box-shadow 0.2s ease;
}

#slideBackground:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    outline: none;
}

.color-picker-wrapper input[type="color"]:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.color-picker-wrapper:active {
    transform: translateY(0) !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3) !important;
}

.slide-element, .slide-thumb-preview {
    transition: background-color 0.2s ease;
}

.text-element [contenteditable] {
    transition: color 0.2s ease;
}

/* Simple icon size increase */
.toolbar-btn i {
    font-size: 1.2em !important;
}

.toolbar {
    padding: 5px 3px;
}

/* Ensure editor area centers content at all zoom levels */
.editor-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 0 !important;
}

/* Canvas should be centered */
#slideCanvas {
    transform-origin: center center !important;
    margin: auto !important;
}

.editor-area {
    display: flex;
    flex-direction: column;
}

/* ========================================
   MOBILE FIX: Make editor area fit slide exactly
   ======================================== */

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        height: auto;        /* override explicit height on mobile */
        max-height: none;
        min-height: unset;
        
         .slides-panel {
            order: 2;
        }
        
        .editor-area {
            order: 1;
        }
    }
    
    .slides-panel {
        width: 100%;
        height: 120px;       /* fixed horizontal strip */
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        flex-shrink: 0;
        flex-direction: row;
        overflow: hidden;
    }

    /* On mobile the list scrolls horizontally */
    .slides-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 8px;
        scrollbar-width: auto;
        scrollbar-color: #c1c1c1 #f1f1f1;
        /* reset min-height:0 that was set for vertical */
        min-height: unset;
    }

    .slide-thumb {
        flex-shrink: 0;
        width: 140px;
        margin-bottom: 0;
    }
    
    .editor-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        background: linear-gradient(135deg, #e8e8e8 0%, #f0f0f0 100%);
        overflow: hidden;
        position: relative;
    }
    
    .editor-wrapper {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 15px;
        min-height: 0;
        overflow: hidden;
        position: relative;
    }
    
    .slide-canvas {
        width: 100%;
        max-width: 100%;
        height: auto !important;
        aspect-ratio: 16 / 9;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
        flex-shrink: 0;
    }
    
    .editor-footer {
        padding: 8px;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .slides-panel {
        height: 100px;
    }
    
    .editor-wrapper {
        padding: 10px;
    }
    
    .slide-canvas {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

/* Ensure the about-section doesn't overflow */
.about-section {
    overflow: hidden;
}

.about-section .container {
    overflow: hidden;
}

/* ========================================
   MOBILE TEXT EDITING FIXES
   ======================================== */

.slide-canvas,
.slide-element,
.text-element,
.text-element [contenteditable] {
    touch-action: manipulation;
}

@media (max-width: 768px) {
    .text-element [contenteditable="true"] {
        font-size: max(16px, inherit) !important;
        -webkit-user-select: text;
        user-select: text;
    }
    
    .slide-canvas:has([contenteditable="true"]) {
        overflow: visible;
    }
    
    .text-element {
        min-height: 44px;
    }
    
    .text-element [contenteditable] {
        padding: 12px 12px 12px 16px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .text-element [contenteditable="true"] {
        outline: 2px solid rgba(37, 99, 235, 0.4) !important;
        outline-offset: 2px;
        background: rgba(255, 255, 255, 0.5);
    }
}

.slide-element {
    -webkit-tap-highlight-color: transparent;
}

.text-element [contenteditable="true"] {
    cursor: text !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

.context-menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

.presentation-actions {
    display: flex;
    gap: 8px;
}

.delete-btn {
    padding: 8px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.delete-btn i {
    font-size: 14px;
}

/* Ensure SweetAlert appears above modals */
.swal2-container {
    z-index: 100000 !important;
}

.swal2-popup {
    z-index: 100001 !important;
}

 @media only screen and (min-width: 992px) {
        #back1 {
            border: 1px solid #EEEEEE;
            border-radius: 3px;
            padding: 2px;
            background-color: #ffffff;
        }
    }
    
/* Save Modal - Clean Design */
#saveModal .modal-content {
    max-width: 600px;
}

#saveModal .modal-body {
    padding: 0;
}

/* Top section with input - fixed */
.save-modal-top {
    padding: 24px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

/* Middle section with list - scrollable */
.save-modal-middle {
    max-height: 350px;
    overflow-y: auto;
    padding: 16px 24px;
    background: #f9fafb;
}

/* Bottom section with buttons - fixed */
.save-modal-bottom {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

#saveModal .presentations-list {
    max-height: none;
    padding: 0;
}

/* Load Modal - Selectable presentation items */
#loadModal .presentation-item {
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

#loadModal .presentation-item:hover {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
}

#loadModal .presentation-item.selected {
    background-color: #dbeafe;
    border-color: #3b82f6;
}

#loadModal .presentation-item.selected .presentation-name {
    color: #1e40af;
    font-weight: 600;
}

/* Delete button styling */
#deleteSelectedPresentation {
    transition: all 0.2s;
}

#deleteSelectedPresentation:hover {
    background: #b91c1c !important;
}

#deleteSelectedPresentation:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
    opacity: 0.5;
}

#openSelectedPresentation:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
    opacity: 0.5;
}

.editor-wrapper {
    position: relative;
}

#slideIndicator {
    text-align: center;
    font-size: 18px;
    color: black;
    background: rgba(224, 225, 225, 0.4);
    font-weight: 500;
    position: absolute;
    bottom: 2px;
    left: 5px;
    padding: 4px 10px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 9999;
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Changed from 280px */
    gap: 16px; /* Slightly smaller gap */
    padding: 0;
}

.template-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.template-card.blank-template {
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.template-card.blank-template:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

.template-thumbnail {
    width: 100%;
    height: 150px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.template-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-thumbnail .placeholder-icon {
    font-size: 48px;
    color: #cbd5e1;
}

.template-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.template-description {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.blank-template-content {
    text-align: center;
}

.blank-template-content i {
    font-size: 48px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.blank-template-content .template-name {
    font-size: 18px;
    color: #6b7280;
}

/* Drag and drop styles for slides */
.slide-thumb {
   /* cursor: move; */
    transition: transform 0.2s, opacity 0.2s;
}

.slide-thumb.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.slide-thumb.drag-over {
    border-top: 3px solid #3b82f6;
}

.slide-thumb:hover {
    transform: translateX(2px);
}

/* Modal loading spinner */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
    grid-column: 1 / -1; /* Span all columns in grid */
    min-height: 200px;
}

.modal-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.modal-loading-text {
    font-size: 14px;
    font-weight: 500;
}

.top-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.top-bar .actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

/* Mobile */
@media (max-width: 768px) {
    .top-bar .actions {
        flex-basis: 100%;
        margin-left: 0;
        margin-top: 10px;
    }
}