/* Visual PDF Editor Styles */

.pdf-editor-visual {
    display: flex;
    flex-direction: column;
    height: 90vh;
    background: var(--dark);
    border-radius: 12px;
    overflow: hidden;
}

/* Toolbar */
.pdf-editor-toolbar {
    display: flex;
    gap: 20px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 5px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.toolbar-group label {
    color: var(--gray-light);
    font-size: 0.9rem;
    margin-right: 5px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--gray-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.tool-btn i {
    pointer-events: none;
}

/* Viewer Container */
.pdf-viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdf-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

#page-info {
    color: var(--gray-light);
    font-size: 0.95rem;
}

#page-info #current-page {
    color: var(--primary);
    font-weight: 600;
}

.zoom-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: 20px;
}

#zoom-level {
    color: var(--primary);
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    flex: 1;
    overflow: auto;
    background: #2a2a2a;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

#pdf-canvas {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

#overlay-canvas {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    cursor: default;
}

/* Save Section */
.pdf-save-section {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.save-button {
    background: linear-gradient(135deg, var(--success), var(--primary));
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.4);
}

.save-button i {
    font-size: 1.2rem;
}

/* Signature Modal */
.signature-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.signature-content {
    background: var(--dark);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.signature-content h3 {
    color: white;
    margin-bottom: 15px;
    text-align: center;
}

.signature-content canvas {
    display: block;
    margin: 0 auto 15px;
    border-radius: 8px;
}

.signature-content button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.signature-content button:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

.signature-content button#clear-signature {
    background: rgba(255, 255, 255, 0.1);
}

.signature-content button#cancel-signature {
    background: var(--danger);
}

/* Color Picker */
#color-picker {
    width: 50px;
    height: 35px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

/* Font Size Input */
#font-size {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 0.9rem;
}

/* Responsive */
/* ===== MOBILE/IPHONE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .pdf-editor-visual {
        height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .pdf-editor-toolbar {
        padding: 10px 8px;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: thin;
        flex-shrink: 0;
        order: 1;
    }

    .toolbar-instructions {
        display: none !important; /* Hide on mobile to save space */
    }

    .toolbar-group {
        gap: 6px;
        padding: 4px 6px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    /* Larger touch targets for mobile */
    .tool-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }

    .pdf-viewer-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        order: 2;
    }

    .pdf-controls {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
        flex-shrink: 0;
    }

    .control-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px 15px;
        font-size: 1rem;
    }

    .page-info {
        font-size: 0.9rem;
        min-width: auto;
        flex: 1;
    }

    .zoom-controls {
        margin-left: 0;
    }

    .canvas-container {
        flex: 1;
        min-height: 0;
        max-height: none;
        padding: 10px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Ensure PDF pages show full width on mobile */
    .pdf-editor-page-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 20px !important;
    }

    .pdf-editor-page-wrapper canvas {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
    }

    input[type="color"],
    input[type="number"],
    select {
        min-height: 44px;
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 8px;
    }

    .toolbar-group label {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .pdf-save-section {
        order: 3;
        flex-shrink: 0;
        padding: 10px;
    }

    .save-button {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
}

/* Extra small phones (iPhone SE, etc.) */
@media (max-width: 480px) {
    .pdf-editor-toolbar {
        padding: 8px 6px;
        gap: 6px;
    }

    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        min-width: 40px;
        min-height: 40px;
    }

    .toolbar-group {
        padding: 4px;
        gap: 4px;
    }

    .control-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .pdf-controls {
        gap: 8px;
        padding: 10px;
    }

    .canvas-container {
        padding: 5px;
    }

    .pdf-editor-page-wrapper {
        margin-bottom: 15px !important;
    }

    /* Better shape selector on small screens */
    .toolbar-group select {
        font-size: 12px;
        padding: 6px;
        min-width: 80px;
    }
}

/* iPhone X and newer (safe area insets) */
@supports (padding: max(0px)) {
    .pdf-editor-toolbar {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .pdf-controls {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* Landscape mode on mobile */
@media (max-width: 900px) and (orientation: landscape) {
    .pdf-editor-toolbar {
        padding: 8px 10px;
    }

    .toolbar-group {
        padding: 4px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .canvas-container {
        max-height: calc(100vh - 150px);
    }
}

/* Loading State */
.pdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2rem;
    text-align: center;
}

.pdf-loading i {
    font-size: 3rem;
    color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Selection Indicator */
.element-selected {
    outline: 2px dashed var(--primary);
    outline-offset: 3px;
}

/* Tooltip */
.tool-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
}

