/**
 * Annotation System Styles
 * Styles for the annotation and e-signature functionality
 */

/* Ensure form layer is properly positioned for annotations */
.form-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through to PDF, but not through annotations */
    z-index: 1050;
}

/* Annotation Field Styles */
.annotation-field {
    position: absolute;
    border: 2px solid #4A9EFF;
    background-color: rgba(74, 158, 255, 0.1);
    border-radius: 4px;
    cursor: move;
    z-index: 1000;
    transition: all 0.2s ease;
    pointer-events: auto; /* Enable interaction with annotations */
    user-select: none; /* Prevent text selection during drag */
}

.annotation-field:hover {
    border-color: #357ABD;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.annotation-field.selected {
    border-color: #FF6B35;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.3);
}

/* Annotation Content */
.annotation-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 8px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    color: #4A9EFF;
    pointer-events: auto;
    overflow: hidden; /* Prevent content overflow */
}

.annotation-content input,
.annotation-content select {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: left;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    outline: none; /* Remove focus outline */
    padding: 2px; /* Add small padding */
    box-sizing: border-box; /* Include padding in size calculation */
}

/* Ensure annotations don't interfere with PDF content */
.annotation-field * {
    pointer-events: auto; /* Enable interaction within annotation */
}

/* Make sure annotations are clearly visible as overlays */
.annotation-field {
    backdrop-filter: none; /* Ensure no blur effects */
    mix-blend-mode: normal; /* Normal blending mode */
    opacity: 0.9; /* Slightly transparent to see PDF underneath */
}

/* Visual feedback for annotation placement mode */
.form-layer.placement-mode {
    cursor: crosshair !important;
    background-color: rgba(74, 158, 255, 0.05); /* Subtle highlight */
    pointer-events: auto; /* Enable interaction for placement */
}

/* Allow interaction when dragging over */
.form-layer.dragging-over {
    pointer-events: auto;
    background-color: rgba(74, 158, 255, 0.05);
}

.form-layer.placement-mode:hover {
    background-color: rgba(74, 158, 255, 0.1);
}

/* Increase opacity when interacting */
.annotation-field:hover,
.annotation-field.selected {
    opacity: 1;
}

/* Ensure resize handles are visible and functional */
.resize-handle {
    pointer-events: auto !important;
    z-index: 1001;
}

.annotation-content input:focus,
.annotation-content select:focus {
    outline: 1px solid rgba(74, 158, 255, 0.5);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #ffffff;
    border: 2px solid #4A9EFF;
    border-radius: 50%;
    cursor: se-resize;
    z-index: 1001;
}

.resize-handle-nw {
    cursor: nw-resize;
    top: -4px;
    left: -4px;
}

.resize-handle-ne {
    cursor: ne-resize;
    top: -4px;
    right: -4px;
}

.resize-handle-sw {
    cursor: sw-resize;
    bottom: -4px;
    left: -4px;
}

.resize-handle-se {
    cursor: se-resize;
    bottom: -4px;
    right: -4px;
}

/* Context Menu */
.annotation-context-menu {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 8px;
    z-index: 2000;
}

.annotation-context-menu div {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 2px;
}

.annotation-context-menu div:hover {
    background-color: #f5f5f5;
}

/* Edit Modal */
.annotation-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    z-index: 5000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.notification-success {
    background-color: #00C48C;
}

.notification-info {
    background-color: #4A9EFF;
}
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #ffffff;
    border: 2px solid #4A9EFF;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.annotation-field:hover .resize-handle,
.annotation-field.selected .resize-handle {
    opacity: 1;
}

.resize-handle:hover {
    background-color: #ffffff;
    transform: scale(1.2);
}

/* Floating field toolbar */
.annotation-field-toolbar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 8px;
}
.annotation-field-toolbar .aft-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
}
.annotation-field-toolbar .aft-btn:hover {
    background: #f7fafc;
    border-radius: 4px;
}
.annotation-field-toolbar .aft-btn.aft-danger:hover {
    background: #ffe7e7;
}
.annotation-field-toolbar .aft-recipient {
    display: flex;
    align-items: center;
    gap: 6px;
}
.annotation-field-toolbar .aft-icon { font-size: 14px; }
.annotation-field-toolbar .aft-select {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
}
.annotation-type-icon { font-size: 12px; opacity: 0.8; }

/* Recipient Styles */
.recipient-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.recipient-item:hover {
    background-color: #e9ecef;
}

.recipient-item.selected {
    background-color: #4A9EFF;
    color: white;
    border-color: #357ABD;
}

.recipient-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.recipient-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.recipient-select-btn {
    background: none;
    border: 1px solid #4A9EFF;
    color: #4A9EFF;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recipient-select-btn:hover {
    background-color: #4A9EFF;
    color: white;
}

.recipient-item.selected .recipient-select-btn {
    border-color: white;
    color: white;
}

.recipient-item.selected .recipient-select-btn:hover {
    background-color: white;
    color: #4A9EFF;
}

/* Add Recipient Button */
.add-recipient-btn {
    background-color: #4A9EFF;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    width: 100%;
    justify-content: center;
}

.add-recipient-btn:hover {
    background-color: #357ABD;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
}

/* Context Menu */
.annotation-context-menu {
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    min-width: 120px;
}

.annotation-context-menu div {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.annotation-context-menu div:hover {
    background-color: #f7fafc;
}

/* Edit Modal */
.annotation-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation-edit-modal > div {
    background: white;
    padding: 24px;
    border-radius: 8px;
    min-width: 320px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.annotation-edit-modal h3 {
    margin: 0 0 16px 0;
    color: #2d3748;
    font-size: 18px;
    font-weight: 600;
}

.annotation-edit-modal label {
    display: block;
    margin: 12px 0;
    font-size: 14px;
    color: #4a5568;
}

.annotation-edit-modal input,
.annotation-edit-modal select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 4px;
}

.annotation-edit-modal input:focus,
.annotation-edit-modal select:focus {
    outline: none;
    border-color: #4A9EFF;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 5000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease;
}

.notification-success {
    background-color: #00C48C;
}

.notification-info {
    background-color: #4A9EFF;
}

.notification-error {
    background-color: #F56565;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Cursor States */
body.annotation-placement-mode {
    cursor: crosshair !important;
}

body.annotation-placement-mode * {
    cursor: crosshair !important;
}

/* Field Button Active State */
.field-btn.active {
    background-color: #0084F0 !important;
    color: white !important;
    border-color: #357ABD !important;
}

.top-tool-btn.field-btn.active {
    background-color: #0084F0 !important;
    color: white !important;
    border: none !important;
}

.top-tool-btn.field-btn.active .field-icon {
    color: var(--primary-blue) !important;
}

/* Upload Section */
.upload-section {
    margin: 20px 0;
    padding: 20px;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-section:hover {
    border-color: #4A9EFF;
    background-color: rgba(74, 158, 255, 0.05);
}

.upload-section.dragover {
    border-color: #4A9EFF;
    background-color: rgba(74, 158, 255, 0.1);
}

.upload-btn {
    background-color: #4A9EFF;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-btn:hover {
    background-color: #357ABD;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

/* Share Modal Enhancements */
.share-modal-content {
    max-width: 600px !important;
}

.share-recipient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin: 8px 0;
    background-color: white;
}

.share-recipient-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.share-recipient-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.share-recipient-name {
    font-weight: 500;
    color: #2d3748;
}

.share-recipient-email {
    font-size: 12px;
    color: #718096;
}

.share-recipient-fields {
    font-size: 12px;
    color: #4a5568;
    background-color: #f7fafc;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .annotation-field {
        min-width: 60px;
        min-height: 20px;
    }
    
    .annotation-content {
        font-size: 12px;
    }
    
    .annotation-edit-modal > div {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Print Styles */
@media print {
    .annotation-field {
        border: 1px solid #000 !important;
        background-color: transparent !important;
    }
    
    .resize-handle,
    .annotation-context-menu,
    .annotation-edit-modal,
    .notification {
        display: none !important;
    }
}
