/* Document Customizer Styles */

/* ==================== CUSTOMIZATION TOOLBAR ==================== */
.customization-toolbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 40;
}

.toolbar-section {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toolbar-btn i {
    font-size: 1rem;
}

.toolbar-select {
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    min-width: 180px;
}

.toolbar-select:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ==================== MODAL STYLES ==================== */
.customizer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.customizer-modal.active {
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px 10px;
}

.modal-close:hover {
    color: #ef4444;
}

.modal-body {
    padding: 25px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    padding: 12px 24px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.btn-secondary:hover {
    border-color: #cbd5e0;
    background: #f8fafc;
}

.btn-upload {
    padding: 20px 30px;
    border-radius: 12px;
    border: 3px dashed #cbd5e0;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    width: 100%;
    font-family: 'Outfit', sans-serif;
}

.btn-upload:hover {
    border-color: #667eea;
    background: #eef2ff;
    color: #667eea;
}

.btn-upload i {
    font-size: 1.5rem;
}

/* ==================== TABS ==================== */
.signature-tabs,
.stamp-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    color: #64748b;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-family: 'Outfit', sans-serif;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==================== LOGO EDITOR ==================== */
.upload-section {
    text-align: center;
    padding: 20px;
}

.help-text {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #64748b;
}

.logo-preview-container {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    margin: 20px 0;
}

.logo-preview-container img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

.logo-controls {
    display: grid;
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
}

.control-group select,
.control-group input[type="range"] {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-family: 'Outfit', sans-serif;
}

.control-group input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* ==================== SIGNATURE EDITOR ==================== */
#signatureCanvas {
    width: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: crosshair;
    background: white;
    touch-action: none;
}

.canvas-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.canvas-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #475569;
}

.canvas-controls input[type="range"] {
    width: 100px;
}

.canvas-controls input[type="color"] {
    width: 50px;
    height: 35px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.signature-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.2rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 15px;
}

.signature-font-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 15px;
}

.signature-preview {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#signatureUploadPreview img {
    max-width: 300px;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
}

/* ==================== STAMP EDITOR ==================== */
.stamp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stamp-option {
    padding: 15px;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.stamp-option:hover {
    border-color: #667eea;
    background: #eef2ff;
}

.stamp-option.selected {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.stamp-preview {
    font-weight: 900;
    font-size: 1.2rem;
    padding: 20px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.stamp-approved {
    color: #10b981;
    border: 3px solid #10b981;
    transform: rotate(-5deg);
}

.stamp-paid {
    color: #3b82f6;
    border: 3px solid #3b82f6;
    transform: rotate(5deg);
}

.stamp-received {
    color: #8b5cf6;
    border: 3px solid #8b5cf6;
}

.stamp-certified {
    color: #f59e0b;
    border: 3px solid #f59e0b;
    transform: rotate(-3deg);
}

.stamp-urgent {
    color: #ef4444;
    border: 3px solid #ef4444;
    transform: rotate(3deg);
}

.stamp-confidential {
    color: #dc2626;
    border: 3px solid #dc2626;
}

.stamp-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 15px;
}

.stamp-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #475569;
}

.stamp-controls input[type="color"] {
    width: 50px;
    height: 35px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.stamp-preview-large {
    background: #f8fafc;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin-top: 20px;
    position: relative;
}

.stamp-preview-large.stamp-circular {
    border-radius: 50%;
    width: 200px;
    height: 200px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stamp-company {
    font-weight: 900;
    font-size: 1rem;
    text-transform: uppercase;
    color: #0f172a;
}

.stamp-text {
    font-weight: 900;
    font-size: 1.5rem;
    text-transform: uppercase;
    color: #ef4444;
    margin: 10px 0;
}

.stamp-date {
    font-weight: 700;
    font-size: 0.8rem;
    color: #64748b;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 15px;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 15px;
}

/* ==================== COLOR PICKER PANEL ==================== */
.color-picker-panel {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 25px;
    z-index: 1000;
    max-width: 350px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateY(-50%) translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
    }
}

.color-picker-panel h4 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 20px;
}

.color-control {
    margin-bottom: 15px;
}

.color-control label {
    display: block;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.color-control input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 10px;
}

.color-control input[type="text"] {
    width: calc(100% - 80px);
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
}

.color-control input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.color-presets {
    margin: 20px 0;
}

.color-presets h5 {
    font-weight: 700;
    color: #475569;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.preset-btn {
    width: 40px;
    height: 40px;
    border: 3px solid white;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preset-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ==================== NOTIFICATIONS ==================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-success {
    background: #10b981;
    color: white;
}

.notification-error {
    background: #ef4444;
    color: white;
}

.notification-info {
    background: #3b82f6;
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ==================== SIGNATURE ELEMENT IN DOCUMENT ==================== */
.signature-element {
    display: inline-block;
    margin: 20px;
    position: relative;
}

.signature-element img {
    max-width: 200px;
    height: auto;
}

/* ==================== QR CODE ==================== */
.qr-code {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

/* ==================== WATERMARK ==================== */
#doc-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 8rem;
    color: rgba(0, 0, 0, 0.05);
    /* Very subtle */
    pointer-events: none;
    z-index: 0;
    user-select: none;
    font-weight: 900;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

/* ==================== QR CODE ==================== */
#doc-qr-code {
    position: absolute;
    bottom: 40px;
    right: 40px;
    width: 100px;
    height: 100px;
    background: white;
    padding: 5px;
    border: 1px solid #eee;
    z-index: 10;
    display: none;
    /* Hidden by default */
}

/* ==================== PRINT OPTIMIZATION ==================== */
@media print {
    @page {
        margin: 0.5cm;
        size: A4;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Hide UI Elements */
    .premium-header,
    .document-toolbar,
    .customization-toolbar,
    .adsense-placeholder,
    .reveal-fade-up.no-print,
    .feedback-link-container,
    footer,
    .no-print {
        display: none !important;
    }

    /* Reset Container */
    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Document Preview Reset */
    .document-preview {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow: visible !important;
    }

    /* Compact Header */
    .doc-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        margin-bottom: 10px !important;
        padding-bottom: 10px !important;
        border-bottom: 2px solid #000 !important;
    }

    .doc-header h3 {
        margin: 0 0 5px 0 !important;
        font-size: 1.2rem !important;
    }

    .doc-header p {
        margin: 0 0 2px 0 !important;
        font-size: 0.9rem !important;
    }

    /* Logo Sizing */
    .logo-area img {
        max-height: 60px !important;
        max-width: 150px !important;
    }

    /* Compact Inputs & Textareas */
    textarea {
        resize: none;
        overflow: hidden;
        min-height: auto !important;
        padding: 2px !important;
        font-size: 9pt !important;
        line-height: 1.1 !important;
    }

    input[type="text"],
    input[type="number"] {
        padding: 2px !important;
        font-size: 9pt !important;
        height: auto !important;
        border: none !important;
        background: transparent !important;
    }

    /* remove borders when printing if desires, or keep them thin */
    .doc-field {
        border-color: #000 !important;
        border-width: 1px !important;
        padding: 5px !important;
    }

    /* Compact Table */
    .doc-table th,
    .doc-table td {
        padding: 4px !important;
        font-size: 9pt !important;
    }

    /* Footer Sizing */
    .doc-footer {
        font-size: 7pt !important;
        margin-top: 10px !important;
        line-height: 1.1 !important;
    }

    /* Watermark Adjust */
    #doc-watermark {
        color: rgba(0, 0, 0, 0.05) !important;
        font-size: 6rem !important;
    }

    #doc-qr-code {
        bottom: 10px;
        right: 10px;
        width: 60px;
        height: 60px;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .customization-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .toolbar-section {
        width: 100%;
        justify-content: center;
    }

    .toolbar-select {
        width: 100%;
    }

    .modal-container {
        width: 95%;
        max-height: 95vh;
    }

    .stamp-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .color-picker-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        transform: none;
        border-radius: 16px 16px 0 0;
        max-width: 100%;
    }

    .canvas-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .canvas-controls input[type="range"] {
        width: 100%;
    }
}

/* ==================== PRINT STYLES (HIDE CUSTOMIZATION UI) ==================== */
@media print {

    .customization-toolbar,
    .customizer-modal,
    .color-picker-panel,
    .notification,
    .toolbar-btn,
    .modal-overlay,
    .modal-container {
        display: none !important;
        visibility: hidden !important;
    }
}