
/* ============================================================
   INVOICE FORM RESPONSIVE GRID
   ============================================================ */
.invoice-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.invoice-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.invoice-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

.auto-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #94a3b8;
    transition: color 0.3s;
}

.auto-save-indicator.saving {
    color: #f59e0b;
}

.auto-save-indicator.saved {
    color: #22c55e;
}

@media (max-width: 768px) {
    .invoice-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .invoice-two-col {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .invoice-item-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
        background: #f8fafc;
        border-radius: 10px;
    }
    
    .invoice-item-row > div:first-child {
        grid-column: 1 / -1;
    }
    
    .invoice-item-row .remove-item {
        grid-column: 1 / -1;
        justify-self: end;
        height: 36px;
        width: 36px;
    }
}

/* ============================================================
   DROPZONE ENHANCEMENTS
   ============================================================ */
.enhanced-dropzone {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.enhanced-dropzone.drag-active {
    border-color: #3b82f6 !important;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.15);
}

.enhanced-dropzone.drag-active .dropzone-icon {
    color: #3b82f6 !important;
    transform: scale(1.1);
}

/* ============================================================
   TRUST BANNER
   ============================================================ */
.tool-trust-banner {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 20px;
    animation: trustBannerSlide 0.4s ease-out;
}

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

.trust-banner-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.trust-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #0369a1;
    white-space: nowrap;
}

.trust-item i {
    font-size: 13px;
    color: #0284c7;
}

@media (max-width: 600px) {
    .trust-banner-content {
        gap: 10px;
    }
    .trust-item {
        font-size: 11px;
    }
}

/* ============================================================
   SMART ERROR MESSAGES
   ============================================================ */
.tool-smart-error {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 16px 18px;
    margin: 0 0 20px 0;
    animation: errorSlide 0.35s ease-out;
    position: relative;
}

.tool-smart-error.fading {
    animation: errorFade 0.5s ease forwards;
}

@keyframes errorSlide {
    from { opacity: 0; transform: translateX(-15px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes errorFade {
    to { opacity: 0; transform: translateY(-8px); }
}

.smart-error-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #dc2626;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.smart-error-content {
    flex: 1;
    min-width: 0;
}

.smart-error-title {
    font-weight: 700;
    font-size: 14px;
    color: #991b1b;
    margin-bottom: 3px;
}

.smart-error-message {
    font-size: 13px;
    color: #b91c1c;
    line-height: 1.5;
}

.smart-error-close {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.smart-error-close:hover {
    opacity: 1;
}

/* ============================================================
   STAGED LOADING STATES
   ============================================================ */
.tool-staged-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px;
    background: #f8fafc;
    border-radius: 16px;
    margin: 20px 0;
    animation: loaderFadeIn 0.3s ease;
}

.tool-staged-loader.hiding {
    animation: loaderFadeOut 0.4s ease forwards;
}

@keyframes loaderFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes loaderFadeOut {
    to { opacity: 0; transform: scale(0.96); }
}

.staged-loader-animation {
    position: relative;
    width: 60px;
    height: 60px;
    margin-bottom: 24px;
}

.staged-loader-spinner {
    width: 100%;
    height: 100%;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: stagedSpin 1s linear infinite;
}

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

.staged-loader-stages {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.staged-stage {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
    transition: color 0.3s;
}

.staged-stage-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: all 0.3s;
    position: relative;
}

.staged-stage-dot.active {
    background: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    animation: stagePulse 1.5s ease infinite;
}

.staged-stage-dot.completed {
    background: #22c55e;
}

.staged-stage-dot.completed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
}

@keyframes stagePulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1); }
}

.staged-loader-progress {
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.staged-loader-bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.staged-loader-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.staged-loader-percent {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    min-width: 36px;
    text-align: right;
}

/* ============================================================
   MOBILE RESPONSIVENESS FIXES
   ============================================================ */
@media (max-width: 768px) {
    /* Tool content padding */
    #toolContent {
        padding: 16px !important;
    }
    
    /* Form groups stack */
    #toolContent .form-group {
        margin-bottom: 14px;
    }
    
    /* Tool actions stack */
    #toolContent .tool-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    #toolContent .tool-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        font-size: 15px;
    }
    
    /* File list items */
    #toolContent .file-item {
        padding: 12px;
        gap: 10px;
    }
    
    #toolContent .file-item-actions {
        gap: 4px;
    }
    
    #toolContent .file-item-actions button {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    /* Settings panels */
    #toolContent .settings-panel {
        padding: 16px;
    }
    
    /* Result areas */
    #toolContent .result-area {
        padding: 16px;
    }
    
    /* Grid layouts become single column */
    #toolContent [style*="grid-template-columns: 1fr 1fr"],
    #toolContent [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Touch targets minimum 44px */
    #toolContent button,
    #toolContent input[type="file"],
    #toolContent select,
    #toolContent .dropzone {
        min-height: 44px;
    }
    
    /* Range sliders bigger on mobile */
    #toolContent input[type="range"] {
        height: 24px;
    }
    
    /* Before/after comparisons stack */
    #toolContent [style*="grid-template-columns: 1fr 1fr"] img,
    #toolContent [style*="grid-template-columns:1fr 1fr"] img {
        max-height: 150px;
    }
}

/* ============================================================
   SIGN PDF EDITOR MOBILE FIXES
   ============================================================ */
@media (max-width: 700px) {
    .sign-pdf-body {
        flex-direction: column !important;
    }
    
    .sign-pdf-thumbnails {
        width: 100% !important;
        height: 80px !important;
        flex-direction: row !important;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .sign-pdf-thumbnails canvas {
        width: 60px !important;
        height: 80px !important;
        flex-shrink: 0;
    }
    
    .sign-pdf-right-panel {
        width: 100% !important;
        height: auto !important;
        max-height: 300px;
    }
    
    .sign-pdf-viewer {
        height: 50vh !important;
    }
    
    .sig-overlay {
        touch-action: none;
    }
}

/* ============================================================
   INVOICE TOOLS MOBILE FIXES
   ============================================================ */
@media (max-width: 768px) {
    #toolContent [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    #toolContent table {
        font-size: 12px;
    }
    
    #toolContent table th,
    #toolContent table td {
        padding: 6px !important;
    }
}
