﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    position: fixed;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #1a1f2e;
    height: 100vh;
    width: 100vw;
    position: fixed;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: #1e2434;
    overflow: hidden;
    position: fixed;
}

/* Top Toolbar */
.top-toolbar {
    background: #232a3c;
    border-bottom: 2px solid #ff9f43;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    height: 56px;
    flex-shrink: 0;
    z-index: 1000;
    position: relative;
    justify-content: space-between;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: fit-content;
}

    .brand a {
        display: flex;
        align-items: center;
        gap: 8px;
        text-decoration: none;
    }

    .brand img {
        height: 36px;
        width: auto;
    }

    .brand i {
        font-size: 22px;
        color: #ff9f43;
    }

    .brand span {
        font-size: 15px;
        font-weight: 600;
        white-space: nowrap;
    }

        .brand span small {
            font-size: 11px;
            color: #8f9bb3;
            margin-left: 4px;
        }

/* Desktop Tool Groups */
.tool-group {
    display: flex;
    gap: 3px;
    background: #2a3145;
    padding: 3px;
    border-radius: 8px;
    flex-wrap: wrap;
}

.desktop-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #a0a8c0;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .tool-btn:hover {
        background: #ff9f43;
        color: #1e2434;
    }

    .tool-btn.active {
        background: #ff9f43;
        color: #1e2434;
    }

/* Page Navigation */
.page-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2a3145;
    padding: 3px 8px;
    border-radius: 8px;
    margin-left: 8px;
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #a0a8c0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .page-btn:hover:not(:disabled) {
        background: #ff9f43;
        color: #1e2434;
    }

    .page-btn:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

#pageIndicator {
    color: white;
    font-size: 14px;
    min-width: 80px;
    text-align: center;
}

#addPageBtn {
    background: #ff9f43;
    color: #1e2434;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

    #addPageBtn:hover {
        background: #ffb66c;
        transform: scale(1.05);
    }

.separator {
    width: 1px;
    height: 30px;
    background: #3a4258;
    margin: 0 5px;
}

/* Panel Toggle Buttons */
.panel-toggle {
    background: #2a3145;
    border: none;
    color: #a0a8c0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

    .panel-toggle:hover {
        background: #ff9f43;
        color: #1e2434;
    }

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: #2a3145;
    border: none;
    color: #a0a8c0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .mobile-menu-btn:hover {
        background: #ff9f43;
        color: #1e2434;
    }

/* Mobile Dropdown Menu */
.mobile-menu {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #232a3c;
    border-bottom: 2px solid #ff9f43;
    padding: 15px;
    z-index: 999;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

    .mobile-menu.active {
        display: block;
    }

.mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.mobile-menu-section {
    margin-bottom: 20px;
}

.mobile-menu-title {
    color: #ff9f43;
    font-size: 13px;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.mobile-menu-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.mobile-menu-btn-item {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #2a3145;
    border: 1px solid #3a4258;
    color: #a0a8c0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: 0.2s;
}

    .mobile-menu-btn-item:hover,
    .mobile-menu-btn-item.active {
        background: #ff9f43;
        color: #1e2434;
        border-color: #ff9f43;
    }

.mobile-menu-wide {
    width: 100%;
    padding: 12px;
    background: #2a3145;
    border: 1px solid #3a4258;
    border-radius: 8px;
    color: white;
    text-align: center;
    margin-bottom: 8px;
    cursor: pointer;
}

/* Main Content - FIXED for proper scrolling */
/*.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;*/ /* Changed from auto to hidden */
    /*position: relative;
    min-height: 0;
    height: calc(100vh - 56px);
    width: 100%;
}*/

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
    height: calc(100vh - 56px);
    width: 100%;
    transition: all 0.3s ease;
}

/* Left Panel - FIXED height and scrolling */
.left-panel {
    width: 280px;
    background: #232a3c;
    border-right: 1px solid #2f384b;
    padding: 15px;
    overflow-y: auto; /* Only panel content scrolls */
    overflow-x: hidden;
    color: white;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    z-index: 90;
    height: 100%; /* Full height */
    max-height: 100%;
    -webkit-overflow-scrolling: touch;
}

    /* Custom scrollbar for left panel */
    .left-panel::-webkit-scrollbar {
        width: 6px;
    }

    .left-panel::-webkit-scrollbar-track {
        background: #2a3145;
    }

    .left-panel::-webkit-scrollbar-thumb {
        background: #ff9f43;
        border-radius: 3px;
    }

    .left-panel.collapsed {
        transform: translateX(-100%);
        position: absolute;
        height: 100%;
    }

/* Right Panel - FIXED height and scrolling */
.right-panel {
    width: 240px;
    background: #232a3c;
    border-left: 1px solid #2f384b;
    padding: 15px;
    color: white;
    overflow-y: auto; /* Only panel content scrolls */
    overflow-x: hidden;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    z-index: 90;
    height: 100%; /* Full height */
    max-height: 100%;
    -webkit-overflow-scrolling: touch;
}

    /* Custom scrollbar for right panel */
    .right-panel::-webkit-scrollbar {
        width: 6px;
    }

    .right-panel::-webkit-scrollbar-track {
        background: #2a3145;
    }

    .right-panel::-webkit-scrollbar-thumb {
        background: #ff9f43;
        border-radius: 3px;
    }

    .right-panel.collapsed {
        transform: translateX(100%);
        position: absolute;
        right: 0;
        height: 100%;
    }

/* Desktop/Laptop - Panels visible by default */
@media (min-width: 769px) {
    .left-panel {
        transform: translateX(0) !important;
        position: relative !important;
    }

    .right-panel {
        transform: translateX(0) !important;
        position: relative !important;
    }

    .left-panel.collapsed {
        transform: translateX(-100%) !important;
        position: absolute !important;
    }

    .right-panel.collapsed {
        transform: translateX(100%) !important;
        position: absolute !important;
    }
}

/* Canvas Area - FIXED to take remaining space */
/*.canvas-area {
    flex: 1 1 0;
    min-width: 0;
    padding: 15px;
    background: #1a1f2e;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;*/ /* Full height */
    /*width: 100%;
    overflow-y: auto;*/ /* Enable scrolling for multiple pages */
    /*-webkit-overflow-scrolling: touch;
}*/

.canvas-area {
    flex: 1 1 auto; /* Changed from 1 1 0 to auto for better flexibility */
    min-width: 0; /* Important for flexbox */
    padding: 15px;
    background: #1a1f2e;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: all 0.3s ease;
}

    /* Custom scrollbar for canvas area */
    .canvas-area::-webkit-scrollbar {
        width: 8px;
    }

    .canvas-area::-webkit-scrollbar-track {
        background: #2a3145;
    }

    .canvas-area::-webkit-scrollbar-thumb {
        background: #ff9f43;
        border-radius: 4px;
    }

/* Pages Container */
/*.pages-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    min-height: min-content;
    padding-bottom: 20px;
}*/

/* Individual Page */
/*.page-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    position: relative;
    width: 100%;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}*/

.pages-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    min-height: min-content;
    padding-bottom: 20px;
    flex: 1 0 auto;
}

/* Page Wrapper - Responsive width */
.page-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    position: relative;
    width: 100%;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: fit-content;
    min-height: 500px;
    max-height: calc(100vh - 150px);
}

    .page-wrapper.active-page {
        border: 2px solid #ff9f43;
        box-shadow: 0 0 0 3px rgba(255,159,67,0.3);
    }

.page-header {
    background: #f8f9fa;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
}

.page-number {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.page-actions {
    display: flex;
    gap: 8px;
}

.page-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

    .page-action-btn:hover {
        background: #ff9f43;
        color: white;
    }

    .page-action-btn.delete-btn:hover {
        background: #dc3545;
    }

/*.canvas-container {
    width: 100%;
    height: 500px;*/ /* Fixed height for each canvas */
    /*background: white;
    position: relative;
}*/

.canvas-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: white;
    position: relative;
    transition: width 0.3s ease, height 0.3s ease;
}

    /* Canvas itself - Make it responsive */
    .canvas-container canvas {
        width: 100% !important;
        height: auto !important;
        max-width: 100%;
        object-fit: contain;
    }

/* Panel Overlay */
.panel-overlay {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 80;
    backdrop-filter: blur(3px);
}

    .panel-overlay.active {
        display: block;
    }

/* Panel Sections */
.panel-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #2f384b;
}

.panel-title {
    color: #ff9f43;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.color-item {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
}

    .color-item:hover {
        transform: scale(1.1);
        border-color: #ff9f43;
    }

    .color-item.selected {
        border-color: #ff9f43;
        box-shadow: 0 0 0 2px rgba(255,159,67,0.3);
    }

/* Slider */
.slider-container {
    margin: 12px 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    color: #8f9bb3;
    font-size: 13px;
    margin-bottom: 5px;
}

.slider {
    width: 100%;
    height: 4px;
    background: #2f384b;
    border-radius: 2px;
    -webkit-appearance: none;
}

    .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        background: #ff9f43;
        border-radius: 50%;
        cursor: pointer;
        border: 2px solid white;
    }

/* Brush Styles */
.style-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.style-btn {
    padding: 10px;
    background: #2a3145;
    border: 1px solid #3a4258;
    border-radius: 6px;
    color: #a0a8c0;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    transition: 0.2s;
}

    .style-btn:hover, .style-btn.active {
        background: #ff9f43;
        color: #1e2434;
        border-color: #ff9f43;
    }

/* Shape Grid */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.shape-btn {
    aspect-ratio: 1;
    background: #2a3145;
    border: 1px solid #3a4258;
    border-radius: 6px;
    color: #a0a8c0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: 0.2s;
}

    .shape-btn:hover {
        background: #ff9f43;
        color: #1e2434;
    }

/* Text Editor */
.text-editor {
    background: #2a3145;
    border-radius: 8px;
    padding: 12px;
}

    .text-editor textarea {
        width: 100%;
        height: 80px;
        background: #1a1f2e;
        border: 1px solid #3a4258;
        border-radius: 6px;
        padding: 8px;
        color: white;
        font-family: inherit;
        resize: vertical;
        margin-bottom: 10px;
        font-size: 13px;
    }

.text-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

    .text-controls select, .text-controls input {
        background: #1a1f2e;
        border: 1px solid #3a4258;
        border-radius: 4px;
        padding: 6px;
        color: white;
        font-size: 13px;
    }

.text-btn {
    width: 32px;
    height: 32px;
    background: #1a1f2e;
    border: 1px solid #3a4258;
    border-radius: 4px;
    color: #a0a8c0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    font-size: 14px;
}

    .text-btn:hover, .text-btn.active {
        background: #ff9f43;
        color: #1e2434;
    }

.action-btn {
    width: 100%;
    padding: 8px;
    background: #ff9f43;
    border: none;
    border-radius: 6px;
    color: #1e2434;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: 0.2s;
    font-size: 13px;
}

    .action-btn:hover {
        background: #ffb66c;
    }

/* Export Buttons */
.export-btn {
    width: 100%;
    padding: 10px;
    background: #2a3145;
    border: 1px solid #3a4258;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    margin-bottom: 6px;
    transition: 0.2s;
    font-size: 13px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .export-btn:hover {
        background: #ff9f43;
        color: #1e2434;
    }

/* Export All Button */
.export-all-btn {
    background: linear-gradient(135deg, #ff9f43, #e67e22);
    border: none;
    color: white;
    font-weight: 600;
}

    .export-all-btn:hover {
        background: linear-gradient(135deg, #e67e22, #ff9f43);
    }

/* Cursors */
.pencil-cursor, .eraser-cursor, .fill-cursor {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    display: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.pencil-cursor {
    color: #ff9f43;
    font-size: 24px;
    transform: translate(-5px, -5px);
}

.eraser-cursor {
    color: white;
    font-size: 28px;
    transform: translate(-8px, -8px);
}

.fill-cursor {
    color: #ff9f43;
    font-size: 28px;
    transform: translate(-10px, -10px);
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #ff9f43;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Brand Text */
.brand-text {
    display: flex;
    align-items: center;
    gap: 4px;
}

.brand-main {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff 0%, #ff9f43 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 1rem;
    font-weight: 400;
    color: #a0a8c0;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(255,159,67,0.3);
    margin-left: 4px;
}

.brand a:hover .brand-main {
    background: linear-gradient(135deg, #ff9f43 0%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand a:hover .brand-sub {
    background: #ff9f43;
    color: #1e2434;
    border-color: #ff9f43;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .desktop-tools {
        gap: 4px;
    }

    .tool-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .page-navigation {
        gap: 4px;
    }

    .page-btn {
        width: 30px;
        height: 30px;
    }

    #pageIndicator {
        min-width: 70px;
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .desktop-tools {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .top-toolbar {
        padding: 6px 10px;
        height: 56px;
    }

    .brand span {
        font-size: 14px;
    }

    .brand img {
        height: 32px;
    }

    .brand-main {
        font-size: 1.2rem;
    }

    .brand-sub {
        font-size: 0.8rem;
        padding: 2px 6px;
    }

    .left-panel, .right-panel {
        position: absolute;
        height: 100%;
        z-index: 90;
        width: 260px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .right-panel {
        right: 0;
        box-shadow: -2px 0 10px rgba(0,0,0,0.3);
    }

    /*.left-panel.collapsed {
        transform: translateX(-100%);
    }

    .right-panel.collapsed {
        transform: translateX(100%);
    }*/

    /* When panels are collapsed, canvas takes full width */
    .left-panel.collapsed + .canvas-area {
        width: 100%;
    }

    .right-panel.collapsed + .canvas-area {
        width: 100%;
    }

    .canvas-area {
        padding: 10px;
    }

    .panel-overlay.active {
        display: block;
    }

    .pencil-cursor, .eraser-cursor, .fill-cursor {
        display: none !important;
    }

    .canvas-container {
        height: 400px;
    }

    .page-navigation {
        margin-left: 4px;
    }

    .page-btn {
        width: 28px;
        height: 28px;
    }

    #pageIndicator {
        min-width: 60px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .top-toolbar {
        padding: 5px 8px;
        height: 50px;
    }

    .brand i {
        font-size: 20px;
    }

    .brand span {
        font-size: 13px;
    }

    .brand img {
        height: 28px;
    }

    .brand-main {
        font-size: 1rem;
    }

    .brand-sub {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    .panel-toggle {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .mobile-menu-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .left-panel {
        width: 240px;
        padding: 12px;
    }

    .right-panel {
        width: 220px;
        padding: 12px;
    }

    .canvas-area {
        padding: 8px;
    }

    .color-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .mobile-menu-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .mobile-menu-btn-item {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .canvas-container {
        height: 350px;
    }

    .page-navigation {
        gap: 2px;
    }

    .page-btn {
        width: 26px;
        height: 26px;
    }

    #pageIndicator {
        min-width: 50px;
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .brand span {
        font-size: 12px;
    }

    .brand-main {
        font-size: 0.9rem;
    }

    .brand-sub {
        font-size: 0.65rem;
    }

    .left-panel {
        width: 220px;
        padding: 10px;
    }

    .right-panel {
        width: 200px;
        padding: 10px;
    }

    .mobile-menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel-section {
        margin-bottom: 15px;
        padding-bottom: 15px;
    }
}

/* Tablet specific */
@media (min-width: 541px) and (max-width: 768px) {
    .left-panel {
        width: 280px;
    }

    .right-panel {
        width: 240px;
    }

    .color-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
    .top-toolbar {
        height: 48px;
    }

    .mobile-menu {
        max-height: calc(100vh - 48px);
    }

    .left-panel, .right-panel {
        padding: 10px;
    }

    .panel-section {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .color-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .canvas-container {
        height: 300px;
    }
}

/* Ensure panels are properly hidden/shown */
@media (max-width: 768px) {
    .left-panel:not(.collapsed),
    .right-panel:not(.collapsed) {
        transform: translateX(0);
    }
}
