﻿/* ============================================================
   QUICK NOTES - Floating Widget Styles
   Tema coerente con il CRM (Navbar dark gradient + cards chiare)
   ============================================================ */

/* ─── FAB (Floating Action Button) ──────────────────────── */

.qn-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .qn-fab.hidden {
        transform: scale(0);
        opacity: 0;
        pointer-events: none;
    }

.qn-fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .qn-fab-btn:hover {
        transform: scale(1.08);
        box-shadow: 0 6px 28px rgba(37, 99, 235, 0.55), 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .qn-fab-btn:active {
        transform: scale(0.96);
    }

/* Badge sul FAB */
.qn-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    animation: qn-pulse 2s infinite;
}

@keyframes qn-pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ─── BACKDROP ──────────────────────────────────────────── */

.qn-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

    .qn-backdrop.visible {
        opacity: 1;
        pointer-events: all;
    }

/* ─── PANEL ─────────────────────────────────────────────── */

.qn-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 400px;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.15), 0 -2px 20px rgba(0, 0, 0, 0.08);
    z-index: 10002;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

    .qn-panel.open {
        transform: translateY(0);
    }

    /* Expanded mode */
    .qn-panel.expanded {
        width: 600px;
        max-height: 92vh;
        right: 20px;
        bottom: 20px;
        border-radius: 16px;
    }

/* ─── PANEL HEADER ──────────────────────────────────────── */

.qn-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: white;
    flex-shrink: 0;
}

.qn-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
}

    .qn-panel-title i {
        font-size: 18px;
        opacity: 0.9;
    }

.qn-count-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.qn-panel-actions {
    display: flex;
    gap: 4px;
}

.qn-btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

    .qn-btn-icon:hover {
        background: rgba(255, 255, 255, 0.2);
    }

/* ─── INPUT AREA ────────────────────────────────────────── */

.qn-input-area {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.qn-textarea {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    resize: none;
    outline: none;
    transition: all 0.2s;
    line-height: 1.5;
}

    .qn-textarea:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .qn-textarea::placeholder {
        color: #94a3b8;
    }

    .qn-textarea.qn-shake {
        animation: qn-shake 0.4s ease;
    }

    .qn-textarea.qn-saved {
        border-color: #10b981;
        background: #ecfdf5;
    }

@keyframes qn-shake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-6px);
    }

    50% {
        transform: translateX(6px);
    }

    75% {
        transform: translateX(-4px);
    }
}

/* Footer input area */
.qn-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    gap: 10px;
}

/* Color picker */
.qn-color-picker {
    display: flex;
    gap: 6px;
}

.qn-color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

    .qn-color-dot:hover {
        transform: scale(1.15);
    }

    .qn-color-dot.active {
        border-color: #1e3a8a;
        box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
        transform: scale(1.15);
    }

/* Priority + Save */
.qn-input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.qn-priority-select {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #64748b;
    background: white;
    cursor: pointer;
    outline: none;
}

.qn-save-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

    .qn-save-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    }

    .qn-save-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

/* ─── TABS ──────────────────────────────────────────────── */

.qn-tabs {
    display: flex;
    padding: 0 20px;
    gap: 4px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.qn-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

    .qn-tab:hover {
        color: #475569;
    }

    .qn-tab.active {
        color: #1e3a8a;
        border-bottom-color: #2563eb;
        font-weight: 600;
    }

    .qn-tab i {
        font-size: 13px;
    }

/* ─── NOTES LIST ────────────────────────────────────────── */

.qn-notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: calc(85vh - 280px);
}

.qn-panel.expanded .qn-notes-list {
    max-height: calc(92vh - 280px);
}

/* Loading */
.qn-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 0;
    color: #94a3b8;
    font-size: 13px;
}

.qn-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: qn-spin 0.7s linear infinite;
}

.qn-spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: qn-spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes qn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
.qn-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
    text-align: center;
}

    .qn-empty i {
        font-size: 32px;
        color: #cbd5e1;
    }

    .qn-empty span {
        font-size: 14px;
        font-weight: 500;
        color: #64748b;
    }

    .qn-empty small {
        font-size: 12px;
        color: #94a3b8;
    }

/* ─── NOTE CARD ─────────────────────────────────────────── */

.qn-note-card {
    display: flex;
    align-items: stretch;
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
}

    .qn-note-card:hover {
        border-color: #e2e8f0;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    }

    .qn-note-card.converted {
        opacity: 0.7;
    }

.qn-note-color-bar {
    width: 5px;
    flex-shrink: 0;
}

.qn-note-body {
    flex: 1;
    padding: 10px 12px;
    min-width: 0;
}

.qn-note-text {
    font-size: 13px;
    color: #1e293b;
    line-height: 1.45;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.qn-note-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.qn-note-time {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 3px;
}

    .qn-note-time i {
        font-size: 10px;
    }

/* Priority tags */
.qn-priority-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

    .qn-priority-tag.low {
        background: #dbeafe;
        color: #1e40af;
    }

    .qn-priority-tag.medium {
        background: #fef3c7;
        color: #92400e;
    }

    .qn-priority-tag.high {
        background: #fee2e2;
        color: #991b1b;
    }

/* Converted badge */
.qn-converted-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    background: #ecfdf5;
    color: #065f46;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Note actions */
.qn-note-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 6px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.qn-note-card:hover .qn-note-actions {
    opacity: 1;
}

.qn-note-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s;
    text-decoration: none;
}

    .qn-note-action-btn:hover {
        background: #f1f5f9;
    }

    .qn-note-action-btn.convert:hover {
        color: #2563eb;
        background: #eff6ff;
    }

    .qn-note-action-btn.archive:hover {
        color: #d97706;
        background: #fffbeb;
    }

    .qn-note-action-btn.delete:hover {
        color: #dc2626;
        background: #fef2f2;
    }

    .qn-note-action-btn.goto:hover {
        color: #059669;
        background: #ecfdf5;
    }

    .qn-note-action-btn.edit:hover {
        color: #7c3aed;
        background: #f5f3ff;
    }

    .qn-note-action-btn.save-edit {
        color: #059669;
    }

        .qn-note-action-btn.save-edit:hover {
            color: #059669;
            background: #ecfdf5;
        }

    .qn-note-action-btn.cancel-edit {
        color: #94a3b8;
    }

        .qn-note-action-btn.cancel-edit:hover {
            color: #dc2626;
            background: #fef2f2;
        }

/* ─── INLINE EDIT MODE ──────────────────────────────────── */

.qn-note-card.editing {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.qn-edit-textarea {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    resize: none;
    outline: none;
    transition: all 0.2s;
    line-height: 1.45;
}

    .qn-edit-textarea:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
    }

.qn-edit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    gap: 8px;
}

.qn-edit-colors {
    display: flex;
    gap: 4px;
}

    .qn-edit-colors .qn-color-dot {
        width: 18px;
        height: 18px;
    }

.qn-edit-priority {
    font-size: 11px;
    padding: 4px 6px;
}

/* ─── CONVERT OVERLAY ───────────────────────────────────── */

.qn-convert-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    z-index: 10;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(4px);
}

.qn-convert-modal {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.qn-convert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

    .qn-convert-header h4 {
        margin: 0;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .qn-convert-header h4 i {
            color: #2563eb;
        }

    .qn-convert-header .qn-btn-icon {
        background: #f1f5f9;
        color: #64748b;
    }

/* Note preview */
.qn-convert-note-preview {
    padding: 12px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.qn-preview-text {
    font-size: 13px;
    color: #334155;
    font-style: italic;
    line-height: 1.45;
}

.qn-preview-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Convert options */
.qn-convert-options {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.qn-convert-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid #f1f5f9;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

    .qn-convert-option:hover {
        border-color: #2563eb;
        background: #eff6ff;
        transform: translateX(3px);
    }

    .qn-convert-option.selected {
        border-color: #2563eb;
        background: #eff6ff;
    }

    .qn-convert-option i {
        font-size: 20px;
        color: #2563eb;
        width: 24px;
        text-align: center;
    }

    .qn-convert-option span {
        font-size: 14px;
        font-weight: 600;
        color: #1e293b;
        display: block;
    }

    .qn-convert-option small {
        font-size: 11px;
        color: #94a3b8;
        display: block;
        margin-top: 1px;
    }

/* Convert form */
.qn-convert-form {
    padding: 12px 20px;
    flex: 1;
    overflow-y: auto;
}

.qn-form-group {
    margin-bottom: 12px;
}

    .qn-form-group label {
        display: block;
        font-size: 12px;
        font-weight: 600;
        color: #64748b;
        margin-bottom: 4px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

.qn-form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s;
}

    .qn-form-input:focus {
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
    }

.qn-form-row {
    display: flex;
    gap: 10px;
}

    .qn-form-row .qn-form-group {
        flex: 1;
    }

/* Convert actions footer */
.qn-convert-actions {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    gap: 10px;
    flex-shrink: 0;
}

.qn-btn-secondary {
    padding: 10px 18px;
    border: 1.5px solid #e2e8f0;
    background: white;
    color: #64748b;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

    .qn-btn-secondary:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
    }

.qn-btn-primary {
    padding: 10px 22px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

    .qn-btn-primary:hover {
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
        transform: translateY(-1px);
    }

    .qn-btn-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

/* ─── TOAST ─────────────────────────────────────────────── */

.qn-toast {
    position: fixed;
    bottom: 90px;
    right: 28px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10010;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

    .qn-toast.visible {
        opacity: 1;
        transform: translateY(0);
    }

.qn-toast-success {
    background: #065f46;
    color: #d1fae5;
}

.qn-toast-error {
    background: #991b1b;
    color: #fee2e2;
}

.qn-toast-info {
    background: #1e3a8a;
    color: #dbeafe;
}

/* ─── RESPONSIVE ────────────────────────────────────────── */

@media (max-width: 480px) {
    .qn-panel {
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
    }

        .qn-panel.expanded {
            width: 100%;
            right: 0;
            bottom: 0;
            max-height: 95vh;
            border-radius: 20px 20px 0 0;
        }

    .qn-fab {
        bottom: 20px;
        right: 20px;
    }

    .qn-fab-btn {
        width: 52px;
        height: 52px;
    }

    .qn-input-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .qn-color-picker {
        justify-content: center;
    }

    .qn-input-actions {
        justify-content: flex-end;
    }

    .qn-form-row {
        flex-direction: column;
        gap: 0;
    }

    .qn-convert-options {
        padding: 12px;
    }
}

/* ─── SCROLLBAR PERSONALIZZATA ──────────────────────────── */

.qn-notes-list::-webkit-scrollbar {
    width: 5px;
}

.qn-notes-list::-webkit-scrollbar-track {
    background: transparent;
}

.qn-notes-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

    .qn-notes-list::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

/* ─── ANIMAZIONE ENTRATA NOTE ───────────────────────────── */

.qn-note-card {
    animation: qn-fadeInUp 0.3s ease forwards;
}

@keyframes qn-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qn-note-card:nth-child(1) {
    animation-delay: 0s;
}

.qn-note-card:nth-child(2) {
    animation-delay: 0.04s;
}

.qn-note-card:nth-child(3) {
    animation-delay: 0.08s;
}

.qn-note-card:nth-child(4) {
    animation-delay: 0.12s;
}

.qn-note-card:nth-child(5) {
    animation-delay: 0.16s;
}
