/* =========================================
   Feature 13: Match Notes Styles
   Theme: Dark Pro
   ========================================= */

:root {
    /* Unified Font Stack */
    --font-main: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* NEW STANDARD VARIABLES */
    --danger: #ef4444;   
    --success: #4ade80;  
}

/* --- 1. ICONS IN MAIN GRID --- */
.note-icon-wrapper { 
    margin-left: 10px;
    position: relative; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    /* Key: wrapper must not clip, but cell needs overflow visible (see bottom) */
    z-index: 5; 
}

.note-icon {
    background: transparent; 
    border: 1px solid transparent;
    color: #475569; /* Inactive State */
    font-size: 14px; 
    cursor: pointer; 
    padding: 0; 
    border-radius: 4px;
    transition: all 0.2s; 
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
}
.note-icon:hover { background: rgba(255,255,255,0.05); color: #fff; }

/* Active State (Notes Exist) */
.note-icon.has-notes {
    color: var(--brand-yellow);
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
}

/* --- TOOLTIP (Fixed: Opens Right, No Clipping) --- */
.note-tooltip {
    visibility: hidden; opacity: 0;
    position: absolute; 
    
    /* POSITION: Right Side */
    left: 100%; 
    top: 50%; 
    transform: translateY(-50%) translateX(10px);
    
    width: 250px; max-height: 200px; 
    
    /* SCROLLBAR FIXES */
    overflow-y: auto; 
    overflow-x: hidden; 
    word-wrap: break-word; 
    
    background-color: #0f172a; 
    border: 1px solid var(--brand-yellow);
    box-shadow: 0 10px 40px rgba(0,0,0,0.9); /* Stronger shadow */
    color: #f1f5f9; font-size: 0.85rem; line-height: 1.4; text-align: left;
    border-radius: 6px; padding: 12px;
    
    /* HIGH Z-INDEX to sit on top of everything */
    z-index: 9999; 
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Arrow (Pointing Left towards Icon) */
.note-tooltip::after {
    content: ""; position: absolute; 
    top: 50%; left: -6px; margin-top: -6px; /* Moved to Left */
    
    border-width: 6px; border-style: solid;
    /* Color the Right border to point Left */
    border-color: transparent var(--brand-yellow) transparent transparent; 
}

/* Trigger Hover */
.note-icon-wrapper:hover .note-icon.has-notes + .note-tooltip {
    visibility: visible; opacity: 1; transform: translateY(-50%) translateX(15px);
}

.tooltip-header { color: var(--brand-yellow); font-weight: 700; margin-bottom: 3px; font-size: 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 2px; }
.tooltip-body { margin-bottom: 10px; white-space: pre-wrap; font-size: 0.8rem; color: #cbd5e1; }
.tooltip-body:last-child { margin-bottom: 0; }

/* Custom Scrollbar for Tooltip */
.note-tooltip::-webkit-scrollbar { width: 4px; }
.note-tooltip::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.note-tooltip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }


/* --- GRID OVERRIDES (Crucial for Tooltip Visibility) --- */

/* 1. Allow the cell to show overflowing content (the tooltip) */
.grid-cell.match-name {
    overflow: visible !important; 
    position: relative; /* Anchor for stacking context */
    z-index: auto;
}

/* 2. But keep the text truncated so it doesn't bleed into the next column */
.grid-cell.match-name > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1; /* Take remaining space */
    min-width: 0; /* Flexbox text truncation fix */
}

/* 3. Ensure wrapper is on top when hovered */
.note-icon-wrapper:hover {
    z-index: 10000;
}


/* --- 2. MODAL --- */
#notes-modal-backdrop.modal-backdrop {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0); 
    backdrop-filter: blur(0);
    z-index: 2500; 
    justify-content: center; align-items: center;
    transition: background 0.4s ease, backdrop-filter 0.4s ease;
}
#notes-modal-backdrop.open { 
    display: flex; 
    background: rgba(15, 23, 42, 0.85); 
    backdrop-filter: blur(5px); 
}

#notes-modal-backdrop .modal-content {
    background: #1e293b; border: 1px solid rgba(255,255,255,0.08);
    width: 600px; max-width: 95vw;
    border-radius: 12px; box-shadow: 0 25px 80px rgba(0,0,0,0.6);
    border-top: 3px solid var(--brand-yellow); 
    display: flex; flex-direction: column; overflow: hidden;
    height: auto; min-height: 400px;
    opacity: 0; transform: scale(1.1); filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#notes-modal-backdrop.open .modal-content { 
    opacity: 1; transform: scale(1); filter: blur(0); 
}

.modal-header { 
    padding: 15px 25px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); 
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(15, 23, 42, 0.3);
}
.modal-header h3 { font-size: 1.1rem; color: #fff; margin: 0; font-weight: 600; }

.close-btn { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 1.2rem; transition: 0.2s; }
.close-btn:hover { color: #fff; }

.modal-body { padding: 25px; overflow-y: auto; flex: 1; }

.view-section { display: none; flex-direction: column; height: 100%; }
.view-section.active { display: flex; animation: fadeUp 0.3s ease-out forwards; }

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

.stats-bar {
    font-size: 0.85rem; color: var(--brand-yellow); margin-bottom: 20px;
    padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05);
}

.note-group { margin-bottom: 20px; display: flex; flex-direction: column; flex: 1; }
.note-label { font-size: 0.85rem; color: #94a3b8; font-weight: 600; margin-bottom: 8px; }

textarea {
    width: 100%; flex: 1; background: #0f172a; border: 1px solid #334155;
    border-radius: 6px; color: #fff; padding: 12px;
    font-family: var(--font-main); font-size: 0.95rem; line-height: 1.5;
    resize: none; transition: 0.2s; min-height: 80px;
}
textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

.confirm-box { text-align: center; padding: 30px 0; }
.warn-icon { font-size: 40px; color: var(--danger); margin-bottom: 15px; }
.confirm-text { font-size: 1.1rem; color: #fff; margin-bottom: 30px; }

.modal-footer { 
    padding: 15px 25px; border-top: 1px solid rgba(255, 255, 255, 0.08); 
    background: rgba(15, 23, 42, 0.3); display: flex; justify-content: space-between; 
}

.btn { 
    padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; 
    border: 1px solid rgba(255,255,255,0.1); transition: all 0.2s; 
    font-size: 0.9rem; font-family: var(--font-main);
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: #00427A; color: white; border-color: rgba(255,255,255,0.1); }
.btn-primary:hover { background: #00569e; border-color: #FFCC00; }

.btn-secondary { background: transparent; color: #94a3b8; }
.btn-secondary:hover { background: rgba(255,255,255,0.05); color: #fff; }

.btn-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }