/* Enterprise PDF Signer (v2) - Enhanced Design with Bootstrap Integration */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
}

.page-wrapper {
    padding: 2rem 1rem;
}

.sign-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 1.5rem;
}

.panel {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.main-panel {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

/* --- Step 1: Choose Screen --- */
.signv2-choose {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    width: 100%;
}

.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.page-header h1 {
    font-size: 1.8rem;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-header p {
    color: #666;
    font-size: 0.95rem;
}

.upload-zone {
    /* Bootstrap classes handle most styles, keeping specific hover/transition */
    transition: all 0.3s ease;
    width: 100%;
    max-width: 600px;
}

.upload-zone:hover {
    border-color: #ec4899 !important;
    background: #fef3f7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* --- Step 2: Editor Screen --- */
.signv2-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Center: Viewer */
.signv2-viewer {
    background: #e2e8f0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    flex: 1;
    min-height: 500px;
}

.signv2-toolbar {
    background: white;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.signv2-toolbar .left, .signv2-toolbar .right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-label {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: center;
    font-size: 0.9rem;
}

.viewer-container {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.signv2-pagewrap {
    position: relative;
    box-shadow: var(--shadow-lg);
    line-height: 0;
}

.page-canvas {
    border-radius: 4px;
}

.signv2-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* Floating Instruction Badge */
.floating-instruction {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    /*gap: 0.75rem; It's not needed, please dont replace this*/
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    z-index: 20;
    backdrop-filter: blur(4px);
    animation: floatDown 0.5s ease-out;
    border: 1px solid rgba(255,255,255,0.1);
}

.floating-instruction i {
    color: #ffffff;
}

@keyframes floatDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.close-instruction {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    margin-left: 0.5rem;
}

.close-instruction:hover {
    color: white;
}

/* Placed Elements */
.placed {
    position: absolute;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.placed:active {
    cursor: grabbing;
}

.placed .box {
    width: 100%;
    height: 100%;
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.placed.selected .box {
    border-style: solid;
    background: rgba(37, 99, 235, 0.15);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(0,0,0,0.15);
}

.placed img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.placed .text {
    font-weight: 600;
    color: var(--text-main);
    font-size: 14px;
    white-space: nowrap;
    pointer-events: none;
}

.placed .handle {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: none;
    z-index: 10;
}

.placed.selected .handle {
    display: block;
}

.placed .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid white;
    z-index: 10;
}

.placed.selected .delete-btn {
    display: flex;
}

.placed .rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: white;
    border: 1px solid var(--primary);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--primary);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 11;
}

.placed.selected .rotate-handle {
    display: flex;
}

.placed .rotate-handle:active {
    cursor: grabbing;
}

/* Right Sidebar: Tools & Info */
.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: #ec4899;
}

.signv2-dropitems {
    /* Bootstrap classes used in HTML */
}

.draggable {
    /* Bootstrap classes used in HTML, keeping specific colors */
}

.ic.sig { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ic.init { background: linear-gradient(135deg, #10b981, #059669); }
.ic.name { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ic.date { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.preview-box {
    /* Bootstrap classes used in HTML */
}

.preview-content {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content img {
    max-height: 40px;
    max-width: 100%;
}

/* Activity Log */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.activity-text {
    display: flex;
    flex-direction: column;
}

.activity-text strong {
    color: #334155;
    font-weight: 600;
}

.activity-text small {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* Info Content (Privacy & Tips) */
.info-group {
    margin-bottom: 2rem;
}

.info-header {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-header i {
    color: #ec4899;
}

.info-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    font-size: 0.875rem;
    color: #4b5563;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.info-list li i {
    color: #10b981; /* Green check */
    margin-top: 0.2rem;
    font-size: 0.8rem;
}

.info-list li i.fa-angle-right {
    color: #ec4899; /* Pink arrow for tips */
}

/* Left Panel Instructions */
.instruction-item {
    padding: 0.75rem;
    background: #f8f9ff;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.instruction-item i {
    color: #ec4899;
    margin-top: 0.2rem;
}

/* Modal */
.signv2-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65); /* Darker backdrop */
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.signv2-modal-backdrop.open {
    display: flex;
}

.signv2-modal {
    background: white;
    width: 100%;
    max-width: 720px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255,255,255,0.1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Modal Sidebar Buttons */
.side-btn {
    /* Bootstrap classes used, adding specific active state */
    border: 0;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    width: 100%;
}

.side-btn:hover {
    background: #fdf2f8;
    color: #831843;
}

.side-btn.active {
    background: linear-gradient(135deg, #fce7f3 0%, #fdf2f8 100%);
    color: #831843;
    box-shadow: 0 2px 5px rgba(236, 72, 153, 0.15);
    border-left: 3px solid #ec4899;
}

.side-btn i {
    width: 24px;
    text-align: center;
    color: #94a3b8;
}

.side-btn.active i {
    color: #ec4899;
}

/* Modal Tabs */
.nav-pills .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 20px;
    padding: 0.5rem 1.5rem;
    transition: all 0.2s ease;
}

.nav-pills .nav-link:hover {
    background-color: #fdf2f8;
    color: #831843;
}

.nav-pills .nav-link.active {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.nav-pills.bg-light {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0;
    padding: 4px !important;
    width: fit-content;
    margin: 0 auto 1.5rem auto;
    border-radius: 25px;
}

/* Color Swatches */
.swatch {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.selected {
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.1);
}

/* Signature Options */
.sig-option {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.sig-option:hover {
    border-color: #f9a8d4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15);
}

.sig-option.selected {
    border-color: #ec4899;
    background: linear-gradient(135deg, #fce7f3 0%, #fdf2f8 100%);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.2);
}

.sig-preview {
    font-size: 1.75rem;
    text-align: center;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Draw Area */
.draw-area {
    /* Bootstrap classes used */
    background: #ffffff;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.03);
}

#drawCanvas {
    cursor: crosshair;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
    display: block;
}

/* Upload Area */
.upload-area {
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: #ec4899 !important;
    background: #fdf2f8 !important;
    transform: scale(1.01);
}

/* Upload File Feedback */
.upload-file-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #fce7f3 0%, #fdf2f8 100%);
    border: 1px solid #f9a8d4;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-file-info .file-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.upload-file-info .file-details {
    flex: 1;
    min-width: 0;
}

.upload-file-info .file-name {
    font-weight: 600;
    color: #831843;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-info .file-size {
    font-size: 0.75rem;
    color: #9f1239;
    margin-top: 0.125rem;
}

.upload-file-info .remove-file {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.125rem;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.upload-file-info .remove-file:hover {
    color: #c82333;
    transform: scale(1.1);
}

/* Loading Overlay */
.signv2-loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

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

.loading-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.loading-sub {
    color: var(--text-muted);
}

/* Success Screen */
.signv2-success {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.signv2-success-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 3rem 2rem;
    text-align: center;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.success-icon {
    font-size: 3rem;
    color: #10b981;
    margin-bottom: 1.5rem;
    background: #ecfdf5;
    width: 5rem;
    height: 5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.signv2-success-card .title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.signv2-success-card .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.security-note {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Thumbnails (if used) */
.signv2-thumb {
    border: 2px solid transparent;
    border-radius: 4px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
}
.signv2-thumb:hover {
    opacity: 1;
    border-color: var(--primary);
}
.signv2-thumb.active {
    opacity: 1;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.signv2-thumb canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 2px;
}
.signv2-thumb .meta {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Modal Body Custom Height */
.modal-body-custom {
    height: 400px;
}

/* Responsive */
@media (max-width: 1200px) {
    .sign-container {
        grid-template-columns: 1fr;
    }

    .main-panel {
        order: 1;
    }

    .panel:last-child {
        order: 2;
    }

    .panel:first-child {
        order: 3;
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        padding: 1rem 0.5rem;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .sign-container {
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .main-panel {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        padding: 1rem;
    }

    .panel {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* PDF Viewer adjustments */
    .signv2-viewer {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .viewer-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .signv2-pagewrap {
        max-width: 100%;
    }

    .page-canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    .signv2-modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    /* Mobile Modal: Horizontal Tabs Layout */
    .modal-body-custom {
        flex-direction: column;
        height: auto !important;
        max-height: none;
        overflow: visible;
    }

    /* Transform sidebar to horizontal tabs */
    .modal-sidebar {
        width: 100%;
        border-right: none !important;
        border-bottom: 2px solid #f1f5f9;
        padding: 0.75rem 1rem !important;
        flex-direction: row !important;
        overflow-x: auto;
        overflow-y: visible;
        min-width: auto !important;
        display: flex !important;
        gap: 0.5rem;
        background: #fafafa;
    }

    .modal-sidebar .d-flex {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem;
        width: 100%;
        min-width: max-content;
    }

    /* Horizontal tab buttons */
    .side-btn {
        width: auto !important;
        flex: 1;
        padding: 0.625rem 1rem !important;
        white-space: nowrap;
        border-left: none !important;
        border-bottom: 3px solid transparent;
        justify-content: center;
        text-align: center;
        font-size: 0.875rem;
        border-radius: 8px 8px 0 0;
        min-width: 90px;
    }

    .side-btn.active {
        border-left: none !important;
        border-bottom: 3px solid #ec4899;
        background: white;
    }

    /* Modal main area - more space on mobile */
    .modal-main {
        padding: 1.25rem !important;
        overflow-y: auto;
        max-height: calc(95vh - 180px);
    }

    .modal-top-inputs {
        grid-template-columns: 1fr;
        padding: 1rem !important;
    }

    .floating-instruction {
        top: 70px;
        width: 90%;
        justify-content: center;
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    /* Adjust signature grid for mobile */
    .sig-grid {
        grid-template-columns: 1fr !important;
    }

    /* Nav pills horizontal and compact */
    .nav-pills.bg-light {
        width: 100% !important;
        display: flex;
        flex-wrap: nowrap;
        margin-bottom: 1rem !important;
        padding: 3px !important;
    }

    .nav-pills .nav-item {
        flex: 1;
    }

    .nav-pills .nav-link {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ========================================
   ADDITIONAL STYLES FROM SIGN.JSP
   ======================================== */

/* Base Reset & Variables Override */
:root {
    --primary-gradient: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    --primary-color: #8b5cf6;
    --surface-color: #ffffff;
    --bg-color: #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    overflow-x: hidden;
}

.page-wrapper {
    padding: 2rem 1rem;
    min-height: calc(100vh - 70px); /* Adjust for header */
}

/* 3-Column Grid Layout (Desktop) */
.sign-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.panel {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.main-panel {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    min-height: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* --- Responsive Layout Logic --- */

/* Tablet: Stack panels differently */
@media (max-width: 1200px) {
    .sign-container {
        grid-template-columns: 1fr; /* Stack vertically */
        gap: 1.5rem;
    }

    /* Order: Main Content (1), Tools (2), Instructions (3) */
    .main-panel { order: 1; }
    #rightPanel { order: 2; }
    .left-column { order: 3; }

    /* Make panels flex to fill width */
    .panel, .main-panel {
        width: 100%;
    }
}

/* Mobile: Optimize spacing and controls */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .page-wrapper {
        padding: 1rem 0.5rem;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .sign-container {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .main-panel {
        padding: 1rem;
        min-height: 400px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .panel {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    /* PDF Viewer mobile fixes */
    .signv2-viewer {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .viewer-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .signv2-pagewrap {
        max-width: 100%;
    }

    .page-canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Responsive Toolbar */
    .signv2-toolbar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .signv2-toolbar .left,
    .signv2-toolbar .right {
        justify-content: space-between;
        width: 100%;
    }

    /* Hide page label on very small screens if needed */
    .page-label {
        font-size: 0.9rem;
    }

    /* Tools Panel Horizontal Grid on Mobile */
    .signv2-dropitems {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
        gap: 0.75rem !important;
    }
}

/* --- Component Styles --- */
.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.page-header h1 {
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: #666;
    font-size: 0.95rem;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: #ec4899;
}

.instruction-item {
    padding: 0.75rem;
    background: #f8f9ff;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.instruction-item i {
    color: #ec4899;
    margin-top: 0.2rem;
}

/* Draggable Cards */
.card[draggable="true"] {
    border: 1px solid #e2e8f0;
    background: white;
    cursor: grab;
    user-select: none;
    touch-action: none; /* Helps with drag on touch devices */
}

.card[draggable="true"]:hover {
    transform: translateY(-2px);
    border-color: #2563eb !important;
    background-color: #f8fafc;
}

/* Drag icons colors */
.ic.sig { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ic.init { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.ic.name { background: linear-gradient(135deg, #10b981, #059669); }
.ic.date { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* --- Modern Modal Styling --- */
.signv2-modal-backdrop {
    /* Ensures backdrop covers everything on mobile */
    padding: 1rem;
    align-items: center;
    justify-content: center;
}

.signv2-modal.compact-modal {
    border-radius: 20px;
    overflow: hidden;
    border: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    width: 800px;
    max-width: 100%;
}

.signv2-modal header {
    background: white;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.5rem !important;
    flex-shrink: 0;
}

.modal-body-custom {
    flex: 1;
    overflow: hidden; /* Contains scroll */
    display: flex;
}

/* Sidebar Styling */
.modal-sidebar {
    background: #fafafa;
    border-right: 1px solid #f1f5f9;
    padding: 1.5rem !important;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.side-btn {
    border: 0;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    width: 100%;
}

.side-btn:hover {
    background: #fdf2f8;
    color: #831843;
}

.side-btn.active {
    background: linear-gradient(135deg, #fce7f3 0%, #fdf2f8 100%);
    color: #831843;
    box-shadow: 0 2px 5px rgba(236, 72, 153, 0.15);
    border-left: 3px solid #ec4899;
}

.side-btn i {
    width: 24px;
    text-align: center;
    color: #94a3b8;
}

.side-btn.active i {
    color: #ec4899;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .signv2-modal.compact-modal {
        height: 100%;
        max-height: 100%;
        border-radius: 0; /* Full screen on mobile */
    }

    .modal-body-custom {
        flex-direction: column; /* Stack sidebar on top */
        overflow: visible;
    }

    /* Fix 2: Sidebar items distributed horizontally */
    .modal-sidebar {
        border-right: none;
        border-bottom: 2px solid #f1f5f9;
        flex-direction: row; /* Horizontal tabs */
        padding: 0.75rem 1rem !important;
        display: flex;
        width: 100%;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: visible;
        background: #fafafa;
    }

    .side-btn {
        flex: 1; /* Distribute evenly */
        padding: 0.625rem 1rem;
        white-space: nowrap;
        font-size: 0.875rem;
        justify-content: center;
        text-align: center;
        border-left: none !important;
        border-bottom: 3px solid transparent;
        border-radius: 8px 8px 0 0;
        min-width: 90px;
    }

    .side-btn.active {
        border-left: none !important;
        border-bottom: 3px solid #ec4899;
        background: white;
    }

    .side-btn i {
        margin-right: 0.4rem;
    }

    .modal-top-inputs .row {
        gap: 0.5rem;
    }

    /* Modal main - more vertical space */
    .modal-main {
        padding: 1.25rem !important;
        overflow-y: auto;
        max-height: calc(95vh - 180px);
    }

    /* Fix 1: Horizontal & Compact Tab Switcher */
    .nav-pills.bg-light {
        width: 100% !important;
        display: flex;
        flex-wrap: nowrap;
        margin-bottom: 1rem !important;
        padding: 3px !important;
    }

    .nav-pills .nav-item {
        flex: 1;
    }

    .nav-pills .nav-link {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* =============================================================================
   SIGN PAGE — DARK THEME OVERRIDES
   Appended at end of file so [data-theme="dark"] beats all light rules above.
   ============================================================================= */
/* Page body background */
[data-theme="dark"] body { background: linear-gradient(135deg, #3b1f6b 0%, #1e1b4b 100%) !important; }
/* Panels & main panel — hardcoded background:white above */
[data-theme="dark"] .panel {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
}
[data-theme="dark"] .panel-title { color: #f1f5f9 !important; }
[data-theme="dark"] .panel-title i { color: #f472b6 !important; }
[data-theme="dark"] .main-panel {
  background: #1e293b !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5) !important;
}
/* Page header */
[data-theme="dark"] .page-header h1 { color: #f1f5f9 !important; }
[data-theme="dark"] .page-header p  { color: #94a3b8 !important; }
/* Upload zone */
[data-theme="dark"] .upload-zone {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .upload-zone:hover {
  background: linear-gradient(135deg, #2d1b4b 0%, #1e293b 100%) !important;
  border-color: #a855f7 !important;
}
/* Toolbar — hardcoded background:white above */
[data-theme="dark"] .signv2-toolbar {
  background: #1e293b !important;
  border-bottom-color: #334155 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}
/* Viewer container */
[data-theme="dark"] .signv2-viewer {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .viewer-container { background: #0f172a !important; }
/* Instruction items — hardcoded background:#f8f9ff above */
[data-theme="dark"] .instruction-item {
  background: #0f172a !important;
  color: #cbd5e1 !important;
}
[data-theme="dark"] .instruction-item i { color: #f472b6 !important; }
/* Info list */
[data-theme="dark"] .info-header { color: #f1f5f9 !important; }
[data-theme="dark"] .info-sub    { color: #94a3b8 !important; }
[data-theme="dark"] .info-list li { color: #cbd5e1 !important; }
/* Activity log items — hardcoded background:#f8fafc above */
[data-theme="dark"] .activity-item {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .activity-text strong { color: #e2e8f0 !important; }
[data-theme="dark"] .activity-text small  { color: #64748b !important; }
/* Draggable tool cards */
[data-theme="dark"] .card[draggable="true"] {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .card[draggable="true"]:hover {
  background: #3d4f67 !important;
  border-color: #60a5fa !important;
}
[data-theme="dark"] .card[draggable="true"] .tx { color: #e2e8f0 !important; }
/* Preview boxes — Bootstrap .bg-light used in HTML */
[data-theme="dark"] .preview-box { background: #0f172a !important; border-color: #334155 !important; }
[data-theme="dark"] .preview-box small { color: #94a3b8 !important; }
[data-theme="dark"] .preview-content { color: #94a3b8 !important; }
/* Loading overlay — hardcoded rgba(255,255,255,0.9) above */
[data-theme="dark"] .signv2-loading {
  background: rgba(15,23,42,0.92) !important;
}
[data-theme="dark"] .loading-text { color: #f1f5f9 !important; }
[data-theme="dark"] .loading-sub  { color: #94a3b8 !important; }
/* Modal backdrop */
[data-theme="dark"] .signv2-modal {
  background: #1e293b !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .signv2-modal header {
  background: #1e293b !important;
  border-bottom-color: #334155 !important;
  color: #f1f5f9 !important;
}
[data-theme="dark"] .signv2-modal header h2 { color: #f1f5f9 !important; }
/* Modal sidebar — hardcoded background:#fafafa above */
[data-theme="dark"] .modal-sidebar {
  background: #0f172a !important;
  border-right-color: #334155 !important;
  border-bottom-color: #334155 !important;
}
[data-theme="dark"] .side-btn { color: #94a3b8 !important; }
[data-theme="dark"] .side-btn:hover {
  background: rgba(168,85,247,0.1) !important;
  color: #e879f9 !important;
}
[data-theme="dark"] .side-btn.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.15) 0%, rgba(236,72,153,0.15) 100%) !important;
  color: #e879f9 !important;
  border-left-color: #ec4899 !important;
}
[data-theme="dark"] .side-btn.active i { color: #f472b6 !important; }
/* Nav pills */
[data-theme="dark"] .nav-pills.bg-light {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .nav-pills .nav-link { color: #94a3b8 !important; }
[data-theme="dark"] .nav-pills .nav-link:hover {
  background: rgba(168,85,247,0.1) !important;
  color: #e879f9 !important;
}
/* Signature options — hardcoded background:white above */
[data-theme="dark"] .sig-option {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .sig-option:hover {
  border-color: #f9a8d4 !important;
  background: rgba(236,72,153,0.05) !important;
}
[data-theme="dark"] .sig-option.selected {
  background: linear-gradient(135deg, rgba(236,72,153,0.1) 0%, rgba(139,92,246,0.1) 100%) !important;
}
/* Draw area */
[data-theme="dark"] .draw-area {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .draw-toolbar {
  background: #1e293b !important;
  border-bottom-color: #334155 !important;
}
[data-theme="dark"] .draw-toolbar span { color: #94a3b8 !important; }
[data-theme="dark"] #drawCanvas {
  background-image: radial-gradient(#334155 1px, transparent 1px) !important;
  background-color: #0f172a !important;
}
/* Upload area in modal */
[data-theme="dark"] #modalUploadArea {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] #modalUploadArea:hover {
  border-color: #8b5cf6 !important;
  background: rgba(139,92,246,0.05) !important;
}
/* Security note */
[data-theme="dark"] .security-note {
  background: #0f172a !important;
  color: #94a3b8 !important;
}
/* Placed element handle */
[data-theme="dark"] .placed .handle { border-color: #1e293b !important; }
/* Form inputs in modal */
[data-theme="dark"] .signv2-modal .form-control,
[data-theme="dark"] .signv2-modal input[type="text"] {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}
[data-theme="dark"] .signv2-modal .form-label { color: #94a3b8 !important; }
/* Separator */
[data-theme="dark"] .separator { border-top-color: #334155 !important; }
/* Bootstrap utility overrides inside sign page */
[data-theme="dark"] .signv2-modal .bg-light { background: #0f172a !important; }
[data-theme="dark"] .signv2-modal .border    { border-color: #334155 !important; }
[data-theme="dark"] .signv2-modal .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .signv2-modal .btn-secondary {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}
/* Toolbar Bootstrap buttons */
[data-theme="dark"] .signv2-toolbar .btn-light,
[data-theme="dark"] .signv2-toolbar .bg-white {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}

/* =============================================================================
   SIGN PAGE — DARK THEME OVERRIDES FOR duc-* UPLOAD WIDGET CLASSES
   Applied when document-upload.css is loaded alongside this file.
   ============================================================================= */
[data-theme="dark"] .fpw-upload-widget {
    --duc-zone-tint:  #1e293b;
    --duc-zone-hover: #2d1b4b;
}
[data-theme="dark"] .duc-header .duc-title-block h1 { color: #f1f5f9 !important; }
[data-theme="dark"] .duc-header .duc-title-block > p { color: #94a3b8 !important; }
[data-theme="dark"] .duc-trust-badge {
    background: rgba(255,255,255,0.05) !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .duc-drop-zone {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .duc-drop-zone:hover,
[data-theme="dark"] .duc-drop-zone.duc-drag-over {
    background: linear-gradient(135deg, #2d1b4b 0%, #1e293b 100%) !important;
    border-color: #ec4899 !important;
}
[data-theme="dark"] .duc-drop-icon       { color: #f472b6 !important; }
[data-theme="dark"] .duc-drop-zone h3    { color: #f1f5f9 !important; }
[data-theme="dark"] .duc-drop-zone > p   { color: #94a3b8 !important; }
[data-theme="dark"] .duc-btn-gdrive {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .duc-size-limit      { color: #64748b !important; }
