/**
 * ============================================================================
 * DOCUMENTS MANAGER STYLES
 * ============================================================================
 * Stili per area documenti con tabs, upload, notifiche
 */

/* ============================================================================
   BLOCCO 1: Container & Layout
   ============================================================================ */

.documents-manager {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.documents-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.documents-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
}

.documents-pratica-badge {
    padding: 4px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.documents-header-actions {
    display: flex;
    gap: 12px;
}

.btn-upload {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-upload:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-notifications {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-notifications:hover {
    background: #f5f5f5;
}

.btn-notifications.has-unread {
    color: #667eea;
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ============================================================================
   BLOCCO 2: Tabs
   ============================================================================ */

.documents-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 16px;
    overflow-x: auto;
}

.documents-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.documents-tab:hover {
    background: #f5f5f5;
    color: #333;
}

.documents-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.documents-tab i {
    font-size: 14px;
}

/* ============================================================================
   BLOCCO 3: Content Area
   ============================================================================ */

.documents-content {
    min-height: 400px;
}

.documents-loading,
.documents-error,
.documents-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #666;
}

.documents-loading i,
.documents-error i,
.documents-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #ccc;
}

.documents-error i {
    color: #ef4444;
}

.documents-empty h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 18px;
}

.documents-empty p {
    margin: 0 0 20px 0;
    font-size: 14px;
}

/* ============================================================================
   BLOCCO 4: Documents List
   ============================================================================ */

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.document-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.document-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.document-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 10px;
    flex-shrink: 0;
}

.document-icon i {
    font-size: 20px;
    color: #667eea;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #999;
}

.document-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.document-pratica {
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-weight: 500;
}

.document-description {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-draft {
    background: #f5f5f5;
    color: #666;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-processing {
    background: #cce5ff;
    color: #004085;
}

.status-ready {
    background: #d4edda;
    color: #155724;
}

.status-sent {
    background: #d1ecf1;
    color: #0c5460;
}

.status-signed {
    background: #d4edda;
    color: #155724;
}

.status-archived {
    background: #e2e3e5;
    color: #383d41;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

.document-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #f5f5f5;
    color: #667eea;
}

.btn-icon.btn-danger:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ============================================================================
   BLOCCO 5: Modals
   ============================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
}

/* ============================================================================
   BLOCCO 6: Upload Modal
   ============================================================================ */

.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 2px dashed #d0d0d0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-dropzone i {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 16px;
}

.upload-dropzone p {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 14px;
}

.upload-browse {
    color: #667eea;
    font-weight: 600;
    text-decoration: underline;
}

.upload-dropzone small {
    color: #999;
    font-size: 12px;
}

.upload-form .form-group {
    margin-bottom: 16px;
}

.upload-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.upload-form select,
.upload-form input,
.upload-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.upload-form select:focus,
.upload-form input:focus,
.upload-form textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.upload-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 16px;
}

.upload-file-info i {
    font-size: 24px;
    color: #667eea;
}

.upload-file-info div {
    flex: 1;
}

.upload-file-info strong {
    display: block;
    font-size: 13px;
    color: #333;
}

.upload-file-info span {
    font-size: 12px;
    color: #999;
}

.upload-file-info button {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
}

.upload-file-info button:hover {
    color: #ef4444;
}

/* ============================================================================
   BLOCCO 7: Notifications Modal
   ============================================================================ */

.notifications-modal {
    max-width: 450px;
}

.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.notification-item.unread {
    background: #f0f4ff;
    border-left: 3px solid #667eea;
}

.notification-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    flex-shrink: 0;
}

.notification-icon i {
    font-size: 14px;
    color: #667eea;
}

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

.notification-content strong {
    display: block;
    font-size: 13px;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.notification-content p {
    margin: 0 0 4px 0;
    font-size: 12px;
    color: #666;
}

.notification-date {
    font-size: 11px;
    color: #999;
}

.notification-action {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    align-self: center;
}

.notification-action:hover {
    background: #764ba2;
}

.notifications-empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.notifications-empty i {
    font-size: 36px;
    margin-bottom: 12px;
}

.notifications-empty p {
    margin: 0;
    font-size: 14px;
}

/* ============================================================================
   BLOCCO 8: Document Details Modal
   ============================================================================ */

.document-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    flex-shrink: 0;
    width: 100px;
}

.detail-row span {
    font-size: 13px;
    color: #333;
    text-align: right;
    word-break: break-word;
}

.detail-row .tag {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 4px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* ============================================================================
   BLOCCO 9: Sister Placeholder
   ============================================================================ */

.sister-placeholder {
    text-align: center;
    padding: 40px 20px;
}

.sister-placeholder i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 16px;
}

.sister-placeholder h4 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: #1a1a1a;
}

.sister-placeholder p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* ============================================================================
   BLOCCO 10: Buttons & Toasts
   ============================================================================ */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f5f5f5;
    color: #333;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 11000;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 3px solid #10b981;
}

.toast-success i {
    color: #10b981;
}

.toast-error {
    border-left: 3px solid #ef4444;
}

.toast-error i {
    color: #ef4444;
}

.toast-info {
    border-left: 3px solid #667eea;
}

.toast-info i {
    color: #667eea;
}

/* ============================================================================
   BLOCCO 10.5: Document Generation Modal
   ============================================================================ */

.btn-generate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.generate-modal {
    max-width: 600px;
}

.document-types-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.document-type-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.document-type-card:hover:not(.disabled) {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.document-type-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9f9f9;
}

.doc-type-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    flex-shrink: 0;
}

.document-type-card.disabled .doc-type-icon {
    background: #e0e0e0;
}

.doc-type-icon i {
    font-size: 24px;
    color: white;
}

.doc-type-info {
    flex: 1;
    min-width: 0;
}

.doc-type-info h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

.doc-type-info p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.coming-soon {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 8px;
    background: #fff3cd;
    color: #856404;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

/* ============================================================================
   BLOCCO 11: Responsive
   ============================================================================ */

@media (max-width: 768px) {
    .documents-manager {
        padding: 16px;
    }

    .documents-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .documents-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .btn-generate,
    .btn-upload {
        flex: 1;
        min-width: 140px;
    }

    .documents-tabs {
        gap: 4px;
    }

    .documents-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .documents-tab span {
        display: none;
    }

    .document-card {
        flex-wrap: wrap;
        gap: 12px;
    }

    .document-info {
        flex: 1 1 calc(100% - 64px);
    }

    .document-status {
        order: 4;
        margin-right: auto;
    }

    .document-actions {
        order: 5;
    }

    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
}

@media (max-width: 480px) {
    .documents-header h2 {
        font-size: 20px;
    }

    .document-meta {
        flex-direction: column;
        gap: 4px;
    }
}

/* ============================================================================
   PREVIEW MODAL STYLES
   ============================================================================ */

.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.preview-content {
    background: white;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.preview-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.preview-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-subtitle {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.preview-header .btn-icon {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.preview-header .btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.preview-container {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    background: #f9fafb;
}

/* Docx-preview content styling */
.preview-container .docx-preview-content {
    background: white;
    padding: 3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    max-width: 900px;
    margin: 0 auto;
    font-family: 'Calibri', 'Arial', sans-serif;
    line-height: 1.6;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .preview-content {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .preview-container {
        padding: 1rem;
    }

    .preview-container .docx-preview-content {
        padding: 1.5rem;
    }

    .preview-header {
        padding: 1rem;
    }

    .preview-header h3 {
        font-size: 1rem;
    }

    .preview-subtitle {
        font-size: 0.75rem;
    }
}
