/* AziSign Modern CSS - Based on React Design System */

:root {
    /* Consolidated Blue Palette */
    --azisign-primary: #2C3E50;           /* Main brand blue */
    --azisign-primary-light: #A6BCCE;     /* Light turquoise accent */
    --azisign-primary-dark: #34495e;      /* Darker variant for hover */
    --azisign-primary-medium: #5D6D7E;    /* Medium tone for secondary */
    
    /* Secondary Colors */
    --azisign-secondary: #718096;
    --azisign-secondary-light: #a0aec0;
    
    /* Status Colors */
    --azisign-success: #48bb78;
    --azisign-warning: #f6ad55;
    --azisign-danger: #f56565;
    --azisign-info: #4299e1;
    
    /* Neutrals */
    --azisign-background: #f8fafc;
    --azisign-surface: #ffffff;
    --azisign-border: #e2e8f0;
    --azisign-border-light: #f1f5f9;
    
    /* Text Colors */
    --azisign-text: #2d3748;
    --azisign-text-muted: #718096;
    --azisign-text-light: #a0aec0;
    
    /* Shadows */
    --azisign-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --azisign-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --azisign-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --azisign-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --azisign-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --azisign-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --azisign-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
.azisign-container {
    background: var(--azisign-background);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', sans-serif;
}

/* Glass Card Component */
.glass-card {
    background: var(--azisign-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--azisign-border);
    border-radius: 12px;
    box-shadow: var(--azisign-shadow);
    transition: var(--azisign-transition);
}

.glass-card:hover.hover-elevate {
    transform: translateY(-2px);
    box-shadow: var(--azisign-shadow-lg);
}

/* Buttons */
.btn-primary {
    background: var(--azisign-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--azisign-transition);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--azisign-shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: var(--azisign-primary-dark);
    box-shadow: var(--azisign-shadow-md);
    color: white;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--azisign-shadow-sm);
}

.btn-secondary {
    background: var(--azisign-surface);
    color: var(--azisign-text);
    border: 1px solid var(--azisign-border);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--azisign-transition);
    cursor: pointer;
    box-shadow: var(--azisign-shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--azisign-border-light);
    border-color: var(--azisign-border);
    transform: translateY(-1px);
    box-shadow: var(--azisign-shadow-md);
    color: var(--azisign-text);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: var(--azisign-shadow-sm);
}

/* Form validation */
.form-control.is-invalid {
    border-color: var(--azisign-danger);
    box-shadow: 0 0 0 0.2rem rgba(245, 101, 101, 0.25);
}

.form-control.is-invalid:focus {
    border-color: var(--azisign-danger);
    box-shadow: 0 0 0 0.2rem rgba(245, 101, 101, 0.25);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--azisign-danger);
}

.btn-danger {
    background: var(--azisign-danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--azisign-transition);
    cursor: pointer;
    box-shadow: var(--azisign-shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-1px);
    box-shadow: var(--azisign-shadow-md);
    color: white;
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-draft {
    background: #f3f4f6;
    color: #6b7280;
}

.status-sent,
.status-waiting,
.status-in_progress {
    background: #fed7aa;
    color: #92400e;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-declined {
    background: #fee2e2;
    color: #991b1b;
}

.status-voided,
.status-cancelled {
    background: #b91c1c;
    color: #ffffff;
}

.status-expired {
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

/* Declined → sender must update the document before continuing */
.status-waiting_update {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    flex-wrap: nowrap;           /* keep one row; scroll horizontally only if needed */
    gap: 8px;
    border-bottom: 2px solid var(--azisign-border);
    margin-bottom: 24px;
    scrollbar-width: thin;       /* subtle scrollbar when it does appear */
}

.tab-btn {
    flex-shrink: 0;              /* tabs keep their size; the row scrolls instead */
    white-space: nowrap;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--azisign-text-muted);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    transition: var(--azisign-transition);
}

.tab-btn:hover {
    color: var(--azisign-text);
}

.tab-btn.active {
    color: var(--azisign-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--azisign-primary);
}

/* Step Indicators */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    transition: var(--azisign-transition);
    cursor: pointer;
}

.step-indicator:hover {
    background: var(--azisign-background);
}

.step-indicator.active {
    background: rgba(44, 62, 80, 0.1);
    color: var(--azisign-primary);
}

.step-indicator.completed {
    background: rgba(72, 187, 120, 0.1);
    color: var(--azisign-success);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    background: var(--azisign-border);
    color: var(--azisign-text-muted);
    transition: var(--azisign-transition);
}

.step-indicator.active .step-number {
    background: var(--azisign-primary);
    color: white;
}

.step-indicator.completed .step-number {
    background: var(--azisign-success);
    color: white;
}

.step-indicator.completed .step-number i {
    font-size: 16px;
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed var(--azisign-border);
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    transition: var(--azisign-transition);
    cursor: pointer;
    background: var(--azisign-surface);
}

.file-upload-area:hover {
    border-color: var(--azisign-primary);
    background: rgba(44, 62, 80, 0.02);
}

.file-upload-area.dragging {
    border-color: var(--azisign-primary);
    background: rgba(44, 62, 80, 0.05);
    border-width: 2px;
}

.file-upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--azisign-background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--azisign-primary);
}

/* File Items */
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--azisign-background);
    border-radius: 8px;
    margin-top: 8px;
    transition: var(--azisign-transition);
}

.file-item:hover {
    background: var(--azisign-border-light);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--azisign-surface);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--azisign-primary);
    font-size: 18px;
    flex-shrink: 0;
}

/* Uploaded-file name + inline rename (name only, extension stays fixed) */
.file-namewrap { display: flex; flex-direction: column; min-width: 0; }
.file-name-row { display: flex; align-items: center; gap: 1px; }
.file-name { font-weight: 500; color: var(--azisign-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.file-ext { color: var(--azisign-text-muted); }
.file-rename-btn { border: none; background: transparent; color: var(--azisign-text-light); cursor: pointer; padding: 2px 6px; font-size: 11px; border-radius: 5px; margin-left: 2px; }
.file-rename-btn:hover { color: var(--azisign-primary); background: var(--azisign-border-light); }
.file-rename-input { max-width: 260px; margin-top: 2px; }

/* Signer Cards */
.signer-card {
    padding: 16px;
    background: var(--azisign-surface);
    border: 1px solid var(--azisign-border);
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--azisign-transition);
}

.signer-card:hover {
    box-shadow: var(--azisign-shadow);
}

.signer-color {
    width: 4px;
    height: 48px;
    border-radius: 4px;
    flex-shrink: 0;
}

.signer-info {
    flex: 1;
}

.signer-order {
    width: 32px;
    height: 32px;
    background: var(--azisign-background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--azisign-text-muted);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--azisign-text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--azisign-border);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--azisign-transition);
    background: var(--azisign-surface);
}

.form-control:focus {
    outline: none;
    border-color: var(--azisign-primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.form-control::placeholder {
    color: var(--azisign-text-light);
}

/* Tables */
.table-modern {
    width: 100%;
    border-collapse: collapse;
}

.table-modern thead {
    background: var(--azisign-background);
}

.table-modern th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--azisign-text);
    border-bottom: 2px solid var(--azisign-border);
}

.table-modern td {
    padding: 16px;
    border-bottom: 1px solid var(--azisign-border-light);
    font-size: 14px;
}

.table-modern tbody tr {
    transition: var(--azisign-transition);
}

.table-modern tbody tr:hover {
    background: var(--azisign-background);
}

/* Fix dropdown menu visibility in table */
.table-responsive {
    overflow: visible !important;
}

.table-modern .dropdown-menu {
    position: absolute !important;
    z-index: 1050 !important;
    min-width: 160px;
    padding: 8px 0;
    margin: 0;
    background: white;
    border: 1px solid var(--azisign-border);
    border-radius: 8px;
    box-shadow: var(--azisign-shadow-lg);
}

.table-modern .dropdown {
    position: relative;
}

.table-modern .dropdown-menu .dropdown-item {
    padding: 8px 16px;
    font-size: 14px;
    color: var(--azisign-text);
    transition: var(--azisign-transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-modern .dropdown-menu .dropdown-item:hover {
    background: var(--azisign-background);
}

.table-modern .dropdown-menu .dropdown-item i {
    width: 16px;
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

/* Loading States */
.spinner {
    border: 3px solid var(--azisign-border);
    border-top-color: var(--azisign-primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, var(--azisign-border) 25%, var(--azisign-border-light) 50%, var(--azisign-border) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Signature Pad */
.signature-pad-container {
    border: 2px solid var(--azisign-border);
    border-radius: 8px;
    background: var(--azisign-surface);
    position: relative;
    margin: 20px 0;
}

.signature-pad {
    width: 100%;
    height: 200px;
    cursor: crosshair;
}

.signature-type-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.signature-type-tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    border: 1px solid var(--azisign-border);
    background: var(--azisign-surface);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--azisign-transition);
}

.signature-type-tab.active {
    background: var(--azisign-primary);
    color: white;
    border-color: var(--azisign-primary);
}

/* PDF Viewer */
.pdf-viewer-container {
    background: var(--azisign-background);
    border-radius: 8px;
    padding: 16px;
    position: relative;
}

.pdf-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--azisign-surface);
    border-radius: 8px;
}

.pdf-canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    background: var(--azisign-surface);
    border-radius: 8px;
    box-shadow: var(--azisign-shadow);
    overflow: hidden;
}

#pdfCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#fieldOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    cursor: default;
}

.placed-field {
    position: absolute;
    background: rgba(255, 255, 255, 0.42);
    border: 1.5px solid #2C3E50;
    border-radius: 3px;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    overflow: visible;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.placed-field:hover {
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
/* (14) Touch: dragging/resizing a field must not scroll the page under the finger. */
.placed-field { touch-action: none; }
.placed-field .resize-handle { touch-action: none; }
/* (15) Selected field (click/tap) — Backspace/Delete removes it. */
.placed-field.pf-selected { outline: 2px solid var(--azisign-primary); outline-offset: 1px; }
/* (14) Bigger finger targets on touch devices (resize handle + remove). */
@media (pointer: coarse) {
    .placed-field .resize-handle { width: 24px !important; height: 24px !important; border-radius: 4px; }
    .placed-field .remove-field { width: 26px; height: 26px; font-size: 18px; }
    .placed-field:hover .pf-dup, .placed-field.pf-selected .pf-dup { display: inline-flex; }
}

.placed-field[data-type="signature"] { border-color: #4CAF50; }
.placed-field[data-type="initials"]  { border-color: #FF9800; }
.placed-field[data-type="date"]      { border-color: #9C27B0; }
.placed-field[data-type="text"]      { border-color: #00BCD4; }

/* WYSIWYG content — sized to match the final stamped output: TOP-anchored
   (content flows top→down inside the box), scales with the box. */
.placed-field .pf-content {
    position: absolute;
    left: 3px; right: 2px; top: 3px; bottom: auto;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.05;
    color: #1a2a3a;
    pointer-events: none;
}
/* Text widget: content fills + justifies to the block width */
.placed-field[data-type="text"] .pf-content {
    right: 3px;
    white-space: normal;
    text-align: justify;
    text-align-last: left;
    word-break: break-word;
}

/* Live size badge (canvas/PowerPoint style) — shows the box size in px while
   hovering or resizing a placed field. */
.placed-field .pf-dims {
    position: absolute;
    bottom: -18px; right: 0;
    font-size: 9.5px; font-weight: 700; line-height: 1;
    background: #2C3E50; color: #fff;
    padding: 2px 5px; border-radius: 3px;
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .12s ease; z-index: 12;
}
.placed-field:hover .pf-dims,
.placed-field.pf-resizing .pf-dims { opacity: 1; }

/* (11) Duplicate control (text widgets) + linked badge */
.placed-field .pf-dup {
    position: absolute; top: -19px; right: 46px;
    width: 18px; height: 18px; padding: 0; z-index: 12;
    border: 1px solid var(--azisign-primary); border-radius: 4px 4px 0 0;
    background: #fff; color: var(--azisign-primary);
    font-size: 9px; line-height: 1; cursor: pointer;
    display: none; align-items: center; justify-content: center;
}
.placed-field:hover .pf-dup { display: inline-flex; }
.placed-field .pf-dup-menu {
    position: absolute; top: 2px; right: 2px; z-index: 20;
    display: flex; flex-direction: column; gap: 2px;
    background: #fff; border: 1px solid var(--azisign-border);
    border-radius: 6px; box-shadow: var(--azisign-shadow-md); padding: 4px;
}
.placed-field .pf-dup-menu button {
    display: flex; align-items: center; gap: 6px;
    border: none; background: transparent; cursor: pointer;
    font-size: 11px; font-weight: 600; color: var(--azisign-text);
    padding: 4px 8px; border-radius: 4px; white-space: nowrap;
}
.placed-field .pf-dup-menu button:hover { background: var(--azisign-background); color: var(--azisign-primary); }
.placed-field .pf-link {
    position: absolute; top: -15px; right: -1px;
    font-size: 8px; color: #fff; background: var(--azisign-primary);
    padding: 2px 4px; border-radius: 3px; line-height: 1; pointer-events: none; z-index: 11;
}
/* (24) Vertical-align cycle button (top / middle / bottom) */
.placed-field .pf-valign {
    position: absolute; bottom: -20px; left: 0;
    width: 22px; height: 18px; padding: 0; z-index: 12;
    border: 1px solid var(--azisign-primary); border-radius: 0 0 4px 4px;
    background: #fff; color: var(--azisign-primary);
    font-size: 10px; line-height: 1; cursor: pointer;
    display: none; align-items: center; justify-content: center;
}
.placed-field:hover .pf-valign,
.placed-field.pf-selected .pf-valign { display: inline-flex; }
/* (font) Bold toggle for typed fields */
.placed-field .pf-bold {
    position: absolute; bottom: -20px; left: 26px;
    width: 22px; height: 18px; padding: 0; z-index: 12;
    border: 1px solid var(--azisign-primary); border-radius: 0 0 4px 4px;
    background: #fff; color: var(--azisign-primary);
    font-size: 10px; line-height: 1; cursor: pointer;
    display: none; align-items: center; justify-content: center;
}
.placed-field .pf-bold.on { background: var(--azisign-primary); color: #fff; }
.placed-field:hover .pf-bold,
.placed-field.pf-selected .pf-bold { display: inline-flex; }

/* Small identity tag (signer + type) — fixed tiny size, shown on hover.
   Does not affect the WYSIWYG content size. */
.placed-field .pf-tag {
    position: absolute;
    top: -15px; left: -1px;
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 9px; font-weight: 700; line-height: 1;
    color: #fff; background: #2C3E50;
    padding: 2px 5px; border-radius: 3px 3px 0 0;
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .12s ease;
}
.placed-field:hover .pf-tag,
.placed-field.pf-selected .pf-tag { opacity: 1; }
.placed-field .pf-tag i { font-size: 8px; }
/* Clickable signer tag → reassign the block to another signer */
.placed-field:hover .pf-tag-btn,
.placed-field.pf-selected .pf-tag-btn { pointer-events: auto; cursor: pointer; }
.placed-field .pf-tag-btn:hover { filter: brightness(1.12); }
.placed-field .pf-tag-caret { font-size: 8px; margin-left: 3px; opacity: .85; }
.placed-field .pf-signer-menu {
    position: absolute; top: 0; left: 0; z-index: 25;
    display: flex; flex-direction: column; gap: 2px;
    background: #fff; border: 1px solid var(--azisign-border);
    border-radius: 7px; box-shadow: var(--azisign-shadow-md); padding: 4px; min-width: 120px;
}
.placed-field .pf-signer-opt {
    display: flex; align-items: center; gap: 7px;
    border: none; background: transparent; cursor: pointer;
    font-size: 11.5px; font-weight: 600; color: var(--azisign-text);
    padding: 5px 8px; border-radius: 5px; white-space: nowrap; text-align: left;
}
.placed-field .pf-signer-opt:hover { background: var(--azisign-background); }
.placed-field .pf-signer-opt.active { background: var(--azisign-primary); color: #fff; }
.placed-field .pf-signer-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.placed-field .pf-signer-empty { padding: 6px 8px; font-size: 11px; color: var(--azisign-text-muted); }

/* Per-field font-size control (text widgets) — always visible so the user can
   type the size in px directly; independent of the box size. */
.placed-field .pf-sizepill {
    position: absolute;
    top: -19px; right: 14px;
    display: inline-flex; align-items: center; gap: 1px;
    height: 18px; padding: 0 5px 0 4px;
    background: #fff; border: 1px solid var(--azisign-primary);
    border-radius: 4px 4px 0 0; box-shadow: 0 -1px 3px rgba(0,0,0,.08);
    z-index: 12; cursor: text;
}
.placed-field .pf-size {
    width: 30px; border: none; background: transparent; outline: none;
    font-size: 10.5px; font-weight: 600; line-height: 1; padding: 0;
    color: var(--azisign-primary); text-align: right;
    -moz-appearance: textfield;
}
.placed-field .pf-size::-webkit-outer-spin-button,
.placed-field .pf-size::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.placed-field .pf-sizeunit { font-size: 9px; font-weight: 700; color: var(--azisign-text-muted); }

.placed-field .remove-field {
    position: absolute;
    top: -8px; right: -8px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #f44336; color: white; border: none;
    font-size: 14px; line-height: 1; cursor: pointer;
    display: none; padding: 0; z-index: 11;
}

.placed-field:hover .remove-field { display: block; }

/* (9) Smart alignment guides — dashed lines while dragging; pink ring when a
   field matches another field's width/height while resizing. */
.azs-align-guide { position: absolute; pointer-events: none; z-index: 30; }
.azs-align-guide.v { width: 0; border-left: 1px dashed #ff3b8b; }
.azs-align-guide.h { height: 0; border-top: 1px dashed #ff3b8b; }
.placed-field.pf-eq-w, .placed-field.pf-eq-h { box-shadow: 0 0 0 2px #ff3b8b; }

/* (10) "Locate field" flash */
.placed-field.pf-flash { animation: pfFlash 1.2s ease; }
@keyframes pfFlash {
    0%, 100% { box-shadow: none; }
    20%, 60% { box-shadow: 0 0 0 3px var(--azisign-primary), 0 0 16px 2px rgba(67,97,238,.55); }
}

/* (10) Placed-objects summary panel */
.azs-objects { display: flex; flex-direction: column; gap: 12px; }
.azs-objects-empty { font-size: 12px; color: var(--azisign-text-muted); padding: 4px 0; }
.azs-objects-count {
    margin-left: auto; font-size: 11px; font-weight: 700; color: var(--azisign-primary);
    background: rgba(67,97,238,.12); border-radius: 10px; padding: 1px 8px;
}
.azs-obj-group { display: flex; flex-direction: column; gap: 4px; }
.azs-obj-signer { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--azisign-text); }
.azs-obj-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border: 1px solid var(--azisign-border); border-radius: 8px;
    background: var(--azisign-surface);
}
.azs-obj-ico { width: 18px; text-align: center; font-size: 12px; flex-shrink: 0; }
.azs-obj-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.azs-obj-type { font-size: 12px; font-weight: 600; color: var(--azisign-text); }
.azs-obj-page { font-size: 10.5px; color: var(--azisign-text-muted); }
.azs-obj-btn {
    width: 26px; height: 26px; flex-shrink: 0; border: none; border-radius: 6px;
    background: transparent; color: var(--azisign-text-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
    transition: var(--azisign-transition-fast);
}
.azs-obj-go:hover { background: rgba(67,97,238,.12); color: var(--azisign-primary); }
.azs-obj-del:hover { background: rgba(220,53,69,.12); color: var(--azisign-danger); }

/* Active field button */
[data-field].active {
    background-color: var(--azisign-primary) !important;
    color: white !important;
    border-color: var(--azisign-primary) !important;
}

.field-placeholder {
    position: absolute;
    border: 2px solid var(--azisign-primary);
    background: rgba(44, 62, 80, 0.1);
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--azisign-primary);
    font-weight: 600;
    user-select: none;
}

.field-placeholder:hover {
    background: rgba(44, 62, 80, 0.2);
}

.field-placeholder.dragging {
    opacity: 0.5;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--azisign-background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--azisign-text-muted);
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--azisign-text);
    margin-bottom: 8px;
}

.empty-state-description {
    color: var(--azisign-text-muted);
    margin-bottom: 24px;
}

/* ============================================================
   Responsive — canonical breakpoints (single source of truth):
     Mobile  : < 768px            -> max-width: 767.98px
     Tablet  : [768px, 1024px)    -> min-width: 768px and max-width: 1023.98px
     Desktop : >= 1024px          -> min-width: 1024px
   Use ONLY these three. Do not introduce other values.
   ============================================================ */
/* Mobile */
@media (max-width: 767.98px) {
    .glass-card {
        border-radius: 8px;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .file-upload-area {
        padding: 32px 16px;
    }
    
    .table-modern {
        font-size: 13px;
    }
    
    .table-modern th,
    .table-modern td {
        padding: 8px 12px;
    }
}

/* Utilities */
.text-primary { color: var(--azisign-primary) !important; }
.text-secondary { color: var(--azisign-secondary) !important; }
.text-success { color: var(--azisign-success) !important; }
.text-warning { color: var(--azisign-warning) !important; }
.text-danger { color: var(--azisign-danger) !important; }
.text-muted { color: var(--azisign-text-muted) !important; }

.bg-primary { background-color: var(--azisign-primary) !important; }
.bg-secondary { background-color: var(--azisign-secondary) !important; }
.bg-success { background-color: var(--azisign-success) !important; }
.bg-warning { background-color: var(--azisign-warning) !important; }
.bg-danger { background-color: var(--azisign-danger) !important; }

.shadow-sm { box-shadow: var(--azisign-shadow-sm) !important; }
.shadow { box-shadow: var(--azisign-shadow) !important; }
.shadow-md { box-shadow: var(--azisign-shadow-md) !important; }
.shadow-lg { box-shadow: var(--azisign-shadow-lg) !important; }
.shadow-xl { box-shadow: var(--azisign-shadow-xl) !important; }

/* Fix modal body shift issue */
body.modal-open {
    padding-right: 0 !important;
    overflow-y: scroll !important;
}

.modal-open .navbar,
.modal-open .azisign-container {
    padding-right: 0 !important;
}

/* Search input group (AziSign) */
.azisign-search-group .input-group-text {
    background: var(--azisign-surface);
    border: 1px solid var(--azisign-border);
    border-right: none;
    color: var(--azisign-text-light);
    border-radius: 8px 0 0 8px;
}

.azisign-search-group .form-control {
    border: 1px solid var(--azisign-border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--azisign-surface);
}

.azisign-search-group .form-control:focus {
    border-color: var(--azisign-primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.azisign-search-group:focus-within .input-group-text {
    border-color: var(--azisign-primary);
}

/* ===== Envelope detail — node timeline =====
   Lives here (not inline) so it is preloaded with the rest of the module CSS
   and the detail view renders fully styled with no flash (FOUC). */
.azs-timeline { position: relative; padding: 6px 0 2px; }
.azs-track { position: absolute; top: 29px; left: calc(100% / 6); right: calc(100% / 6);
             height: 4px; background: #e5e7eb; border-radius: 2px; z-index: 0; }
.azs-track-fill { height: 100%; width: 0; background: #10b981; border-radius: 2px;
                  transition: width .45s ease; }
.azs-timeline.is-cancelled .azs-track-fill { background: #ef4444; }
.azs-timeline.is-expired   .azs-track-fill { background: #9ca3af; }
.azs-timeline.is-waiting-update .azs-track-fill { background: #f59e0b; }

.azs-nodes { position: relative; z-index: 1; display: flex; }
.azs-node { flex: 1 1 0; text-align: center; padding: 0 4px; }
.azs-circle { width: 50px; height: 50px; border-radius: 50%; margin: 0 auto 12px;
              display: flex; align-items: center; justify-content: center;
              font-size: 18px; color: #fff; background: #cbd5e1;
              border: 3px solid #fff; box-shadow: 0 0 0 2px #e5e7eb;
              transition: background .2s, box-shadow .2s; }
.azs-node.created   .azs-circle { background: #2563eb; box-shadow: 0 0 0 2px #2563eb; }
.azs-node.done      .azs-circle { background: #10b981; box-shadow: 0 0 0 2px #10b981; }
.azs-node.active    .azs-circle { background: #f59e0b; box-shadow: 0 0 0 5px rgba(245,158,11,.22); }
.azs-node.pending   .azs-circle { background: #cbd5e1; box-shadow: 0 0 0 2px #e5e7eb; }
.azs-node.cancelled .azs-circle { background: #ef4444; box-shadow: 0 0 0 2px #ef4444; }
.azs-node.expired   .azs-circle { background: #9ca3af; box-shadow: 0 0 0 2px #9ca3af; }
.azs-title { font-weight: 600; font-size: 13.5px; color: var(--azisign-text); }
.azs-time  { font-size: 12px; color: var(--azisign-text-muted); margin-top: 2px; }

/* Vertical timeline on mobile */
@media (max-width: 767.98px) {
  .azs-timeline .azs-track { top: 25px; bottom: 25px; left: 25px; right: auto; width: 4px; height: auto; }
  .azs-timeline .azs-track-fill { display: none; }
  .azs-nodes { flex-direction: column; gap: 22px; }
  .azs-node { display: flex; align-items: center; gap: 14px; text-align: left; padding: 0; }
  .azs-circle { margin: 0; flex: 0 0 auto; }
}

/* ===== Detail view: smooth entrance (avoid abrupt render) ===== */
@keyframes azsFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.azs-detail { animation: azsFadeIn .22s ease-out both; }

/* ===== Signers filter bar ===== */
.azs-filters .azs-filter-input { width: 190px; }
.azs-filters .azs-filter-select { width: auto; min-width: 145px; }
.azs-filters input.azs-filter-select { width: 170px; }
.azs-filters .azs-filter-clear { border-width: 1.5px; font-weight: 600; }
.azs-filters .azs-filter-clear:hover { color: #fff; }
.azs-filters .input-group-text { background: #f8fafc; border-color: var(--azisign-border); color: var(--azisign-text-muted); }
.azs-filters .form-control, .azs-filters .form-select { border-color: var(--azisign-border); }
.azs-filters .form-control:focus, .azs-filters .form-select:focus {
  border-color: var(--azisign-primary); box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.08);
}

/* ===== Sortable columns ===== */
.azs-signers thead th { white-space: nowrap; }
.azs-signers .azs-sortable { cursor: pointer; user-select: none; transition: color .15s; }
.azs-signers .azs-sortable:hover { color: var(--azisign-primary); }
.azs-signers .azs-sort-ic { font-size: 10px; opacity: .4; margin-left: 3px; }
.azs-signers .azs-sortable.azs-asc .azs-sort-ic,
.azs-signers .azs-sortable.azs-desc .azs-sort-ic { opacity: 1; color: var(--azisign-primary); }

/* ============================================================
   aziSign field-placement editor (3-pane: toolrail · doc · panel)
   ============================================================ */
.azs-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 540px;
    background: var(--azisign-surface);
    border: 1px solid var(--azisign-border);
    border-radius: 14px;
    box-shadow: var(--azisign-shadow-md);
    overflow: hidden;
}

/* ---- Top bar ---- */
.azs-editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    background: var(--azisign-surface);
    border-bottom: 1px solid var(--azisign-border);
    flex-shrink: 0;
}
.azs-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.azs-topbar-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; color: var(--azisign-text); font-size: 14px;
    white-space: nowrap;
}
.azs-topbar-title i { color: var(--azisign-primary); }
.azs-topbar-right { display: flex; align-items: center; gap: 8px; }
.azs-actions { display: flex; align-items: center; gap: 8px; }

.azs-pagenav {
    display: flex; align-items: center; gap: 4px;
    background: var(--azisign-background);
    border: 1px solid var(--azisign-border);
    border-radius: 9px; padding: 3px 6px;
}
.azs-pagenav-btn {
    width: 28px; height: 28px; border: none; border-radius: 7px;
    background: transparent; color: var(--azisign-text-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: var(--azisign-transition-fast); font-size: 13px;
}
.azs-pagenav-btn:hover:not(:disabled) { background: var(--azisign-surface); color: var(--azisign-primary); box-shadow: var(--azisign-shadow-sm); }
.azs-pagenav-btn:disabled { opacity: .35; cursor: default; }
.azs-pagenav-label { font-size: 12.5px; font-weight: 600; color: var(--azisign-text); padding: 0 4px; min-width: 54px; text-align: center; }
.azs-pagenav-sep { color: var(--azisign-text-light); font-weight: 400; }

/* doc selector slot reuses .pdf-controls markup but stays inline/transparent */
.azs-docselect { background: transparent; padding: 0; margin: 0; border-radius: 0; }
/* Document switcher cluster — same look as the page navigator (.azs-pagenav). */
.azs-docnav { gap: 2px; }
.azs-docnav-select {
    border: none; background: transparent; outline: none;
    font-size: 12.5px; font-weight: 600; color: var(--azisign-text);
    max-width: 200px; padding: 0 4px; cursor: pointer; text-align: center;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
.azs-docnav-select:focus { outline: none; }

.btn-sm.btn-primary, .btn-sm.btn-secondary { padding: 7px 12px; font-size: 13px; }

/* ---- Body ---- */
.azs-editor-body { display: flex; flex: 1; min-height: 0; }

/* Left toolrail */
.azs-toolrail {
    width: 54px; flex-shrink: 0;
    background: var(--azisign-background);
    border-right: 1px solid var(--azisign-border);
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 12px 0;
}
.azs-tool {
    width: 38px; height: 38px; border: 1px solid transparent; border-radius: 9px;
    background: transparent; color: var(--azisign-text-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 15px; transition: var(--azisign-transition-fast);
}
.azs-tool:hover { background: var(--azisign-surface); color: var(--azisign-primary); border-color: var(--azisign-border); box-shadow: var(--azisign-shadow-sm); }
.azs-tool-danger:hover { color: var(--azisign-danger); border-color: var(--azisign-danger); }
.azs-tool-zoom { font-size: 10.5px; font-weight: 700; color: var(--azisign-text-muted); letter-spacing: .2px; }
.azs-tool-sep { width: 24px; height: 1px; background: var(--azisign-border); margin: 4px 0; }

/* Center document stage. `safe center` centers the page when it fits but falls
   back to start-alignment when it's bigger than the viewport, so the left/top
   edges stay reachable by scrolling (plain centering clips them when zoomed in). */
.azs-doc-stage {
    flex: 1; min-width: 0; overflow: auto;
    /* allow 1-finger pan/scroll but let JS handle 2-finger pinch-zoom of the doc */
    touch-action: pan-x pan-y;
    display: flex; justify-content: safe center; align-items: safe center;
    padding: 28px;
    background:
        radial-gradient(circle at 1px 1px, rgba(44,62,80,.06) 1px, transparent 0) 0 0 / 22px 22px,
        var(--azisign-background);
}
.azs-doc-stage .pdf-canvas-container {
    position: relative; overflow: visible; flex: 0 0 auto;
    background: #fff; border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,.16);
}
.azs-doc-stage #pdfCanvas { display: block; border-radius: 4px; }

/* Continuous multi-page stack */
.azs-pages { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.azs-page {
    position: relative; flex: 0 0 auto;
    background: #fff; border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,.16);
}
.azs-page > canvas { display: block; border-radius: 4px; }
.azs-page::before {
    content: "Page " attr(data-page);
    position: absolute; top: -19px; left: 1px;
    font-size: 10.5px; font-weight: 600; color: var(--azisign-text-muted);
    letter-spacing: .3px;
}
.azs-page-overlay { position: absolute; top: 0; left: 0; }
.azs-page-overlay.azs-drop-hot { background: rgba(44,62,80,.06); outline: 2px dashed var(--azisign-primary); outline-offset: -2px; }
.azs-page.azs-page-current::after {
    content: ""; position: absolute; inset: -2px;
    border: 2px solid var(--azisign-primary-light); border-radius: 6px; pointer-events: none;
}

/* Right panel */
.azs-rightpanel {
    width: 312px; flex-shrink: 0; overflow-y: auto;
    background: var(--azisign-surface);
    border-left: 1px solid var(--azisign-border);
    padding: 16px;
    display: flex; flex-direction: column; gap: 20px;
}
.azs-panel-section { display: flex; flex-direction: column; gap: 10px; }
.azs-panel-head {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700; color: var(--azisign-text);
    text-transform: none;
}
.azs-panel-hint {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--azisign-border-light); color: var(--azisign-text-muted);
    font-size: 10px; font-weight: 700; font-style: italic;
    display: inline-flex; align-items: center; justify-content: center; cursor: help;
}

/* Recipients */
.azs-recipients { display: flex; flex-direction: column; gap: 8px; }
.azs-rec-empty { font-size: 12.5px; color: var(--azisign-text-muted); padding: 10px 12px; background: var(--azisign-background); border-radius: 9px; text-align: center; }
.azs-recipient {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px; border: 1px solid var(--azisign-border); border-radius: 10px;
    background: var(--azisign-surface); cursor: pointer;
    transition: var(--azisign-transition-fast); position: relative;
}
.azs-recipient:hover { border-color: var(--azisign-primary-light); box-shadow: var(--azisign-shadow-sm); }
.azs-recipient.active { border-color: var(--azisign-primary); background: rgba(44,62,80,.05); box-shadow: inset 3px 0 0 var(--azisign-primary); }
.azs-rec-dot { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; }
.azs-rec-dot::after { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; opacity: 0; }
.azs-recipient.active .azs-rec-dot::after { opacity: 1; }
.azs-rec-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.azs-rec-name { font-size: 13px; font-weight: 600; color: var(--azisign-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.azs-rec-email { font-size: 11.5px; color: var(--azisign-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.azs-rec-role { font-size: 10.5px; font-weight: 700; color: var(--azisign-primary); background: var(--azisign-border-light); border-radius: 6px; padding: 3px 7px; flex-shrink: 0; }
/* Receiver (CC) recipients: muted, not a field target */
.azs-recipient.azs-rec-iscc { cursor: default; }
.azs-recipient.azs-rec-iscc:hover { border-color: var(--azisign-border); box-shadow: none; }
.azs-recipient.azs-rec-iscc .azs-rec-role { color: #64748b; background: #eef2f7; }
/* Recipient role <select> inside the signer card */
.signer-card .signer-role { font-size: 12px; }
.azs-rec-remove { width: 26px; height: 26px; border: none; background: transparent; color: var(--azisign-text-light); border-radius: 7px; cursor: pointer; flex-shrink: 0; transition: var(--azisign-transition-fast); }
.azs-rec-remove:hover { background: rgba(245,101,101,.12); color: var(--azisign-danger); }

.azs-addrec { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--azisign-background); border-radius: 10px; }
.azs-addrec-actions { display: flex; justify-content: flex-end; gap: 8px; }
.azs-addrec-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 10px; border: 1.5px dashed var(--azisign-border);
    border-radius: 10px; background: transparent; color: var(--azisign-primary);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--azisign-transition-fast);
}
.azs-addrec-btn:hover { border-color: var(--azisign-primary); background: rgba(44,62,80,.04); }

/* Widgets */
.azs-widget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.azs-widget {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 8px 8px 8px 10px; border: 1px solid var(--azisign-border); border-radius: 10px;
    background: var(--azisign-surface); color: var(--azisign-text);
    font-size: 12.5px; font-weight: 600; cursor: grab; transition: var(--azisign-transition-fast);
    text-align: left;
}
.azs-widget:hover { border-color: var(--azisign-primary); box-shadow: var(--azisign-shadow-sm); transform: translateY(-1px); }
.azs-widget.active { border-color: var(--azisign-primary); background: rgba(44,62,80,.06); box-shadow: 0 0 0 2px rgba(44,62,80,.12); }
.azs-widget.azs-dragging { opacity: .5; }
.azs-widget-label { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.azs-grip { color: var(--azisign-text-light); font-size: 10px; }
.azs-widget-ico { width: 28px; height: 28px; border-radius: 7px; background: var(--azisign-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.azs-widget-tip { font-size: 11px; color: var(--azisign-text-muted); margin: 2px 0 0; line-height: 1.4; }

/* Drop affordance on the overlay */
#fieldOverlay.azs-drop-hot { background: rgba(44,62,80,.06); outline: 2px dashed var(--azisign-primary); outline-offset: -2px; }

/* ===== Editor responsive (canonical breakpoints) =====
   Desktop (>=1024): full 3-pane (toolrail · document · right panel).
   Tablet + Mobile (<1024): stack — horizontal toolrail, document, panel below. */
@media (max-width: 1023.98px) {
    .azs-editor { height: auto; min-height: 0; }
    .azs-editor-body { flex-direction: column; }
    .azs-toolrail {
        width: auto; flex-direction: row; flex-wrap: wrap; justify-content: center;
        border-right: none; border-bottom: 1px solid var(--azisign-border);
        gap: 8px; padding: 8px;
    }
    .azs-tool-sep { width: 1px; height: 24px; margin: 0 4px; }
    /* (5) Cap the document window so only the document scrolls (the whole page
       no longer grows tall as fields are placed). */
    .azs-doc-stage { height: 64vh; max-height: 64vh; min-height: 320px; padding: 18px; }
    /* (7) Recipients + Widgets sit on top, above the document. */
    .azs-rightpanel {
        width: auto; border-left: none; border-top: 1px solid var(--azisign-border);
        order: -1; border-bottom: 1px solid var(--azisign-border); border-top: none;
    }
}
/* Tablet [768,1024): right-panel sections side by side */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .azs-rightpanel { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
    .azs-rightpanel .azs-panel-section { flex: 1 1 280px; }
}
/* Mobile (<768): tighter top bar, drop the centre title, full-width doc */
@media (max-width: 767.98px) {
    .azs-editor-topbar { flex-wrap: wrap; gap: 8px; }
    .azs-topbar-title { display: none; }
    .azs-topbar-left, .azs-topbar-right { flex: 1 1 auto; justify-content: center; }
    .azs-doc-stage { padding: 14px; }
    .azs-rightpanel .azs-widget-grid { grid-template-columns: 1fr 1fr; }
    /* Page + document switchers relocated into the doc tools panel (toolrail). */
    .azs-toolrail-mobile { row-gap: 8px; }
    .azs-toolrail-mobile .azs-pagenav,
    .azs-toolrail-mobile #docSelectorSlot { flex: 0 0 auto; display: inline-flex; align-items: center; }
    .azs-toolrail-mobile .azs-docnav-select { max-width: 150px; }
    /* Recipients stay as a vertical list on mobile. */
    .azs-rightpanel .azs-recipients { display: flex; flex-direction: column; gap: 8px; }
    .azs-rightpanel .azs-recipient { width: 100%; }
}

/* ===== Dashboard / envelope list ===== */
/* Elegant flat search (replaces the segmented "3D" input-group) */
.azs-search { position: relative; width: 100%; }
.azs-search i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--azisign-text-light); font-size: 13px; pointer-events: none;
}
.azs-search input {
    width: 100%; height: 40px; padding: 0 14px 0 38px;
    border: 1px solid var(--azisign-border); border-radius: 10px;
    background: var(--azisign-background); color: var(--azisign-text);
    font-size: 14px; transition: var(--azisign-transition-fast);
}
.azs-search input::placeholder { color: var(--azisign-text-light); }
.azs-search input:focus {
    outline: none; border-color: var(--azisign-primary); background: var(--azisign-surface);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, .10);
}

/* Stat cards: identical height + width */
.azs-stat-card { display: flex; }
.azs-stat-card .card-body { width: 100%; overflow: hidden; }
.azs-stat-cards .azs-stat-card { min-height: 104px; }
/* Keep the icon inside the card (it overflowed on narrow tablet columns) */
.azs-stat-card .card-body > .d-flex { gap: 8px; }
.azs-stat-card .card-body > .d-flex > div:first-child { min-width: 0; }
.azs-stat-card .card-body > .d-flex > div:last-child { flex-shrink: 0; }

/* Toolbar (tabs + search): one row; scroll horizontally ONLY when the tabs
   don't fit (overflow:auto shows no scrollbar while they fit). */
.azs-toolbar .tab-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Tablet: shrink the stat icon + padding so the card never breaks */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .azs-stat-card .card-body { padding: 16px !important; }
    .azs-stat-card .card-body .fa-2x { font-size: 1.35em; }
}

/* Tablet + mobile: stack the toolbar — search on top, tabs below */
@media (max-width: 1023.98px) {
    .azs-toolbar > .azs-toolbar-tabs,
    .azs-toolbar > .azs-toolbar-search { flex: 0 0 100%; max-width: 100%; }
    .azs-toolbar > .azs-toolbar-search { order: -1; margin-bottom: 12px; }
}

/* Tablet + Mobile (<1024): tables scroll horizontally inside their card
   instead of overflowing it (overrides the desktop `overflow: visible`). */
@media (max-width: 1023.98px) {
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .table-modern { min-width: 760px; }
    .azs-signers { min-width: 720px; }
}

/* Detail filters: full-width, stacked inside the drawer on mobile */
@media (max-width: 767.98px) {
    .azs-detail .azs-filters { flex-direction: column; align-items: stretch; margin-bottom: 0 !important; }
    .azs-detail .azs-filters .azs-filter-select,
    .azs-detail .azs-filters .azs-filter-clear { width: 100%; }
    /* (1) Detail header: title + id/dates centered */
    .azs-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .azs-detail-headinfo { width: 100%; }
    .azs-detail-meta { justify-content: center; }
    /* (2) Header action buttons as an equal 2×2 grid.
       display:grid !important to beat Bootstrap's .d-flex (display:flex !important),
       otherwise the full-width buttons wrap one-per-row (stacked). */
    .azs-detail-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
    .azs-detail-actions > * { width: 100%; min-height: 42px; margin: 0;
        display: inline-flex; align-items: center; justify-content: center; }
}
/* (3) Filters drawer: narrower than Bootstrap's default 400px */
.azs-filters-oc.offcanvas-md { --bs-offcanvas-width: 300px; }
/* Tablet/desktop: the offcanvas renders inline — drop its body padding */
@media (min-width: 768px) {
    .azs-filters-oc .offcanvas-body { padding: 0; }
}

/* (4) Upload list: keep the rename pencil + remove button inside the grey box
   (the long file name truncates instead of pushing them out). */
.file-item { position: relative; padding-right: 44px; }
.file-item .file-info { flex: 1 1 auto; min-width: 0; }
.file-item .file-namewrap { flex: 1 1 auto; min-width: 0; }
.file-item .file-name-row { min-width: 0; gap: 2px; }
.file-item .file-name { max-width: none; min-width: 0; flex: 0 1 auto; }
.file-item .file-ext { flex-shrink: 0; }
/* Pencil = a clear, tappable edit button (notably separated from the delete) */
.file-item .file-rename-btn {
    flex-shrink: 0;
    width: 30px; height: 30px;
    margin-left: 6px;
    border: 1px solid var(--azisign-border, #e3e7ee);
    border-radius: 8px;
    background: #fff;
    color: var(--azisign-primary, #4361ee);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.file-item .file-rename-btn:hover { background: var(--azisign-background, #f4f6fa); border-color: var(--azisign-primary, #4361ee); }
/* Delete = round nav-style circle in the top-right corner */
.file-item > [data-action="remove-file"] {
    position: absolute; top: 8px; right: 8px;
    width: 26px; height: 26px; padding: 0;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1; flex-shrink: 0;
}

/* (2) Mobile: Save Draft sits on its own first row as a quiet borderless button,
   the "Create Envelope" title drops to the next row. */
@media (max-width: 767.98px) {
    .azs-create-header { flex-direction: column-reverse; align-items: stretch; gap: 2px; }
    .azs-create-header .azs-create-title { width: 100%; }
    .azs-savedraft-top {
        align-self: flex-end;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--azisign-primary, #4361ee) !important;
        padding: 2px 6px !important;
        font-weight: 600;
    }
}

/* (5) Signer card: number + delete sit top-right (like a toolbar); the name/email
   inputs take the full remaining width. */
.signer-card { position: relative; align-items: stretch; padding: 40px 16px 16px 18px; }
.signer-card .signer-color { position: absolute; left: 0; top: 0; bottom: 0; height: auto; border-radius: 8px 0 0 8px; }
.signer-card .signer-info { flex: 1 1 auto; min-width: 0; }
.signer-card .signer-order { position: absolute; top: 8px; right: 48px; margin: 0; }
.signer-card .remove-signer { position: absolute; top: 9px; right: 10px; }

/* ===== Wizard top stepper (icons + connecting track, all modes) ===== */
.azs-wizard-steps {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    background: var(--azisign-surface); border: 1px solid var(--azisign-border);
    border-radius: 14px; padding: 18px 20px; box-shadow: var(--azisign-shadow-sm);
}
.azs-wstep { flex: 1 1 0; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.azs-wstep:not(:last-child)::after {           /* track to the next step */
    content: ""; position: absolute; top: 21px; left: 50%; width: 100%; height: 2px;
    background: var(--azisign-border); z-index: 0;
}
.azs-wstep.completed:not(:last-child)::after { background: var(--azisign-success); }
.azs-wstep-ico {
    position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--azisign-border-light); color: var(--azisign-text-light);
    border: 2px solid var(--azisign-border); font-size: 16px;
    transition: var(--azisign-transition-fast);
}
.azs-wstep-label { font-size: 12.5px; font-weight: 600; color: var(--azisign-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.azs-wstep.active .azs-wstep-ico { background: var(--azisign-primary); color: #fff;
    border-color: var(--azisign-primary); box-shadow: 0 0 0 4px rgba(44, 62, 80, .12); }
.azs-wstep.active .azs-wstep-label { color: var(--azisign-primary); }
.azs-wstep.completed .azs-wstep-ico { background: var(--azisign-success); color: #fff; border-color: var(--azisign-success); }
.azs-wstep.completed .azs-wstep-label { color: var(--azisign-text); }
/* Mobile: smaller, icons only (keeps it one tidy row) */
@media (max-width: 767.98px) {
    .azs-wizard-steps { padding: 14px 10px; }
    .azs-wstep-ico { width: 36px; height: 36px; font-size: 14px; }
    .azs-wstep:not(:last-child)::after { top: 18px; }
    .azs-wstep-label { display: none; }
}

/* ===== Icon colour pass (brand accents on otherwise-dull icons) ===== */
.azisign-container h1 > i:first-child,
.azs-detail h1 > i:first-child { color: var(--azisign-primary); }
.glass-card .card-body > h5 > i:first-child,
.glass-card .card-body > h6 > i:first-child { color: var(--azisign-primary); }
.azs-detail .glass-card h5 > i:first-child { color: var(--azisign-primary); }
.empty-state-icon i { color: var(--azisign-primary-light); }
/* Detail header action buttons — distinct accents */
.azs-detail .btn-outline-secondary i { color: var(--azisign-primary); }

/* Mobile (<768): title centered on its own line; the actions become a single
   horizontally-scrollable row; stat cards hidden. */
/* ===== Page chrome around aziSign (sticky footer, compact content) =====
   The base layout is a flex column (body.d-flex.flex-column, min-height:100vh).
   <main> fills the remaining height so the footer sits at the bottom, but the
   content itself stays its NATURAL height (no stretched empty white card). Any
   residual space lands in <main> (subtle body background), NOT inside
   .azisign-container. Scope via body.azisign-page. */
body.azisign-page main#main-content {
    margin-top: 12px !important; margin-bottom: 0 !important;
    padding-top: 0 !important; padding-bottom: 0 !important;
    flex: 0 0 auto !important;          /* don't grow — the footer hugs the content */
}
body.azisign-page .azisign-container { min-height: auto; }
/* Footer flows right after the content (kill the base mt-auto that pushed it
   to the viewport bottom and created the big gap). */
body.azisign-page .footer { margin-top: 0 !important; }
/* The editor step should still use the full available height. */
body.azisign-page #step-3 .azs-editor { min-height: calc(100vh - 220px); }

@media (max-width: 767.98px) {
    /* Even tighter on mobile + full width (no side padding from main) */
    body.azisign-page main#main-content {
        margin-top: 8px !important; margin-bottom: 8px !important;
        padding-left: 0 !important; padding-right: 0 !important; max-width: 100% !important;
    }

    /* (1) Use almost the full screen width + (5) tighter vertical spacing.
       !important to beat Bootstrap's .px-4/.py-4 utility (which are !important).
       Also keep page-level horizontal scroll off (wide blocks scroll inside). */
    .azisign-container .container-fluid {
        /* clip (not hidden) so horizontal page-scroll stays off WITHOUT forcing
           overflow-y to 'auto' — that was clipping the autocomplete dropdown. */
        overflow-x: clip;
        padding-left: 10px !important; padding-right: 10px !important;
        padding-top: 10px !important; padding-bottom: 10px !important;
    }

    /* (2) Title on its own line with breathing room above the menu */
    .azs-page-header { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 16px !important; }
    .azs-page-title { text-align: center; margin-bottom: 2px; }

    /* (4) Menu: the three buttons share the full row, equal width + height.
       They stretch to fill the width (not by shrinking the text — labels wrap). */
    .azs-page-actions { flex-wrap: nowrap; overflow: visible; gap: 6px; }
    .azs-page-actions > * { flex: 1 1 0; min-width: 0; }
    .azs-page-actions .btn,
    .azs-page-actions .btn-primary {
        box-sizing: border-box; min-height: 46px; border: 1px solid transparent;
        display: flex; align-items: center; justify-content: center; gap: 5px;
        padding: 6px 6px; font-size: 12.5px; line-height: 1.15;
        white-space: normal; text-align: center;
    }
    .azs-page-actions .btn { border-color: var(--azisign-border); }

    /* Hide stat cards on mobile */
    .azs-stat-cards { display: none; }

    /* (3) Compact table — content-sized columns, tighter padding, no wasted gap */
    .table-modern { min-width: 0 !important; width: auto; }
    .table-modern thead th { width: auto !important; }
    .table-modern th, .table-modern td { padding: 7px 9px; font-size: 12.5px; white-space: nowrap; }
}