/* =============================================
   Client Notes Widget — cn- prefix
   ============================================= */

/* Floating Action Button */
.cn-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--color-accent, #c9a84c);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cn-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.cn-fab svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Badge */
.cn-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    pointer-events: none;
}

.cn-fab-badge:empty,
.cn-fab-badge[data-count="0"] {
    display: none;
}

/* Sidebar Note Count Badge */
.cn-sidebar-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--color-accent, #c9a84c);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    flex-shrink: 0;
}

/* Overlay */
.cn-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 198;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cn-overlay.cn-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Slide-in Panel */
.cn-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: #fff;
    z-index: 199;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
}

.cn-panel.cn-panel-open {
    transform: translateX(0);
}

.cn-fab.cn-fab-hidden {
    pointer-events: none;
    opacity: 0;
}

/* Panel Header */
.cn-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border, #e8e5e0);
    flex-shrink: 0;
}

.cn-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text, #2d2d2d);
}

.cn-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.cn-panel-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Panel Actions (Export / Import) */
.cn-panel-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border, #e8e5e0);
    flex-shrink: 0;
}

.cn-panel-actions button {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    border: 1px solid var(--color-border, #e8e5e0);
    background: #fff;
    color: var(--color-text-secondary, #6b7280);
    transition: background 0.15s, color 0.15s;
}

.cn-panel-actions button:hover {
    background: #f9fafb;
    color: var(--color-text, #2d2d2d);
}

.cn-panel-actions .cn-import-label {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    border: 1px solid var(--color-border, #e8e5e0);
    background: #fff;
    color: var(--color-text-secondary, #6b7280);
    transition: background 0.15s, color 0.15s;
    text-align: center;
}

.cn-panel-actions .cn-import-label:hover {
    background: #f9fafb;
    color: var(--color-text, #2d2d2d);
}

.cn-panel-actions .cn-import-input {
    display: none;
}

/* Panel Body — scrollable notes list */
.cn-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* Empty State */
.cn-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--color-text-secondary, #6b7280);
    font-size: 14px;
    line-height: 1.5;
}

.cn-empty svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.35;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

/* Note Card */
.cn-note-card {
    border-left: 3px solid var(--color-accent, #c9a84c);
    background: #fafaf8;
    border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
    padding: 12px 14px;
    margin-bottom: 12px;
    position: relative;
    transition: box-shadow 0.15s;
}

.cn-note-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.cn-note-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cn-note-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text, #2d2d2d);
}

.cn-note-date {
    font-size: 11px;
    color: var(--color-text-secondary, #6b7280);
    margin-left: auto;
}

.cn-note-text {
    font-size: 13.5px;
    line-height: 1.55;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Note action buttons row */
.cn-note-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

.cn-note-card:hover .cn-note-actions {
    opacity: 1;
}

.cn-note-edit,
.cn-note-delete {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border, #e8e5e0);
    background: #fff;
    cursor: pointer;
    color: #9ca3af;
    border-radius: var(--radius-sm, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.cn-note-edit:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.cn-note-delete:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Edited label */
.cn-note-edited {
    font-style: italic;
    opacity: 0.7;
}

/* Inline edit textarea */
.cn-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    border: 1px solid var(--color-accent, #c9a84c);
    border-radius: var(--radius-sm, 4px);
    resize: vertical;
    outline: none;
    margin-top: 6px;
    box-sizing: border-box;
    background: #fff;
    color: var(--color-text, #2d2d2d);
}

/* Edit save/cancel buttons */
.cn-edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
}

.cn-edit-save,
.cn-edit-cancel {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    border: none;
}

.cn-edit-save {
    background: var(--color-accent, #c9a84c);
    color: #fff;
}

.cn-edit-save:hover {
    background: var(--color-accent-hover, #b8933b);
}

.cn-edit-cancel {
    background: #f3f4f6;
    color: var(--color-text-secondary, #6b7280);
    border: 1px solid var(--color-border, #e8e5e0);
}

.cn-edit-cancel:hover {
    background: #e5e7eb;
}

/* Hide actions row while editing */
.cn-note-card.cn-editing .cn-note-actions {
    display: none;
}

/* Bottom Form */
.cn-form {
    flex-shrink: 0;
    border-top: 1px solid var(--color-border, #e8e5e0);
    padding: 14px 20px;
    background: #fafaf8;
}

.cn-form-author {
    width: 100%;
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid var(--color-border, #e8e5e0);
    border-radius: var(--radius-sm, 4px);
    margin-bottom: 8px;
    outline: none;
    transition: border-color 0.15s;
    background: #fff;
    color: var(--color-text, #2d2d2d);
    box-sizing: border-box;
}

.cn-form-author:focus {
    border-color: var(--color-accent, #c9a84c);
}

.cn-form-input {
    width: 100%;
    min-height: 72px;
    padding: 9px 10px;
    font-size: 13.5px;
    border: 1px solid var(--color-border, #e8e5e0);
    border-radius: var(--radius-sm, 4px);
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    background: #fff;
    color: var(--color-text, #2d2d2d);
    box-sizing: border-box;
}

.cn-form-input:focus {
    border-color: var(--color-accent, #c9a84c);
}

.cn-form-submit {
    width: 100%;
    margin-top: 8px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    background: var(--color-accent, #c9a84c);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    transition: background 0.15s;
}

.cn-form-submit:hover {
    background: var(--color-accent-hover, #b8933b);
}

.cn-form-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Confirmation Modal */
.cn-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cn-modal-overlay.cn-modal-visible {
    opacity: 1;
}

.cn-modal {
    background: #fff;
    border-radius: var(--radius-md, 8px);
    padding: 24px;
    width: 320px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.cn-modal-visible .cn-modal {
    transform: scale(1);
}

.cn-modal-message {
    font-size: 14px;
    color: var(--color-text, #2d2d2d);
    margin: 0 0 20px;
    line-height: 1.5;
    text-align: center;
}

.cn-modal-actions {
    display: flex;
    gap: 10px;
}

.cn-modal-cancel {
    flex: 1;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid var(--color-border, #e8e5e0);
    border-radius: var(--radius-sm, 4px);
    background: #fff;
    color: var(--color-text-secondary, #6b7280);
    cursor: pointer;
    transition: background 0.15s;
}

.cn-modal-cancel:hover {
    background: #f3f4f6;
}

.cn-modal-confirm {
    flex: 1;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm, 4px);
    background: #dc2626;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.cn-modal-confirm:hover {
    background: #b91c1c;
}

/* Responsive — full-width panel on small screens */
@media (max-width: 480px) {
    .cn-panel {
        width: 100%;
    }

    .cn-fab {
        bottom: 16px;
        right: 16px;
    }

    /* Prevent iOS Safari auto-zoom on focus (requires >= 16px) */
    .cn-form-author,
    .cn-form-input,
    .cn-edit-textarea {
        font-size: 16px;
    }
}
