/* ========================================
   GOEDITPDF - RESPONSIVE MOBILE
   ======================================== */

/* === TABLET === */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }
}

/* === MOBILE BASE === */
@media (max-width: 900px) {
    .hamburger {
        display: block;
        z-index: 25;
    }

    .top-bar {
        height: 55px;
        padding: 0 0.75rem;
    }

    .brand {
        font-size: 1.1rem;
    }

    .brand span {
        display: none;
    }

    .header-actions .btn-tool span {
        display: none;
    }

    .header-actions {
        gap: 5px;
    }

    .header-actions .btn-tool {
        padding: 6px 10px;
    }

    /* SIDEBAR OVERLAY */
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease;
        z-index: 20;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    #sidebarOverlay {
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(2px);
    }

    /* PROPERTIES BOTTOM SHEET */
    .floating-props {
        top: auto !important;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        border-top: 2px solid var(--primary);
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    /* ZOOM CONTROLS */
    .zoom-controls {
        bottom: 20px;
        right: 20px;
        padding: 4px;
        gap: 4px;
    }

    .btn-zoom {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    /* UPLOAD ZONE */
    .upload-zone {
        padding: 2.5rem 1.5rem;
        max-width: 92%;
    }

    .upload-zone h1 {
        font-size: 1.6rem;
    }

    .upload-zone i {
        font-size: 3rem;
    }

    /* PAGES */
    .scroll-area {
        padding: 30px 10px;
    }

    .page-wrapper {
        margin-bottom: 25px;
        max-width: calc(100vw - 30px) !important;
    }

    /* MODALS */
    .modal {
        width: 92%;
        max-width: 450px;
        max-height: 85vh;
        overflow-y: auto;
    }

    #sigCanvas {
        width: 100% !important;
        height: 180px !important;
    }

    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .tools-grid-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
}

/* === MOBILE SMALL === */
@media (max-width: 500px) {
    .top-bar {
        height: 50px;
        padding: 0 0.5rem;
    }

    .brand {
        font-size: 1rem;
    }

    .lang-select {
        padding: 4px 8px;
        font-size: 0.8rem;
        margin-left: 5px;
    }

    .header-actions .btn-tool {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
    }

    .header-actions .btn-tool span {
        display: none !important;
    }

    .header-actions .btn-tool i {
        margin: 0;
    }

    .upload-zone {
        padding: 1.5rem 1rem;
        max-width: 95%;
    }

    .upload-zone h1 {
        font-size: 1.3rem;
    }

    .upload-zone p {
        font-size: 0.9rem;
    }

    .upload-zone i {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .zoom-controls {
        bottom: 15px;
        right: 15px;
        padding: 3px;
        gap: 3px;
    }

    .btn-zoom {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    #zoomLevel {
        font-size: 0.8rem;
        margin: 0 3px;
    }

    .sidebar {
        width: 260px;
    }

    .modal {
        width: 95%;
        max-width: none;
        padding: 15px;
    }

    #sigCanvas {
        height: 150px !important;
    }

    .floating-props {
        padding: 0.75rem;
        max-height: 65vh;
    }

    .prop-row {
        margin-bottom: 8px;
    }

    .prop-label {
        font-size: 0.75rem;
        width: 50px;
    }

    .scroll-area {
        padding: 20px 5px;
    }

    .page-wrapper {
        margin-bottom: 20px;
    }

    .page-info-tag {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* === TOUCH DEVICES === */
@media (hover: none) and (pointer: coarse) {
    .btn-tool,
    .btn-zoom,
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-height: 44px;
        min-width: 44px;
    }

    .canvas-container {
        touch-action: none;
        -webkit-user-select: none;
        user-select: none;
    }

    .canvas-container canvas {
        touch-action: none;
    }

    .scroll-area {
        -webkit-user-select: none;
        user-select: none;
    }

    .btn-tool:active,
    .btn-zoom:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* === LANDSCAPE MOBILE === */
@media (max-width: 900px) and (orientation: landscape) {
    .top-bar {
        height: 48px;
    }

    .floating-props {
        max-height: 50vh;
    }

    .upload-zone {
        padding: 1.5rem 1rem;
    }

    .upload-zone h1 {
        font-size: 1.4rem;
    }

    .upload-zone i {
        font-size: 2.5rem;
        margin-bottom: 0.5rem;
    }
}

/* === SAFE AREA (iPhone X+) === */
@supports (padding: max(0px)) {
    .top-bar {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .sidebar {
        padding-left: max(1rem, env(safe-area-inset-left));
    }

    .zoom-controls {
        bottom: max(30px, calc(30px + env(safe-area-inset-bottom)));
        right: max(30px, calc(30px + env(safe-area-inset-right)));
    }

    .floating-props {
        padding-bottom: max(1rem, calc(1rem + env(safe-area-inset-bottom)));
    }
}

/* === SCROLLBARS === */
.sidebar::-webkit-scrollbar,
.floating-props::-webkit-scrollbar,
.scroll-area::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.floating-props::-webkit-scrollbar-thumb,
.scroll-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* === PREVENT OVERSCROLL (iOS) === */
body {
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

.scroll-area {
    overscroll-behavior: contain;
}

/* === REDUCE MOTION === */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .floating-props,
    .btn-tool,
    .zoom-controls,
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}