/* 1. TAILWIND v4 IMPORT */
@import "tailwindcss";

/* 2. GLOBAL BASE STYLES */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    background-color: #f8fafc;
    font-family: 'Inter', sans-serif;
    overscroll-behavior-y: none; /* Prevents mobile pull-to-refresh bounce */
}

.h-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* --- 3. RESPONSIVE BEHAVIOR --- */

/* MOBILE & TABLET: Natural scrolling */
@media (max-width: 1023px), (pointer: coarse) {
    html, body {
        overflow-y: auto !important; 
        height: auto !important; 
        position: relative !important;
    }
    
    .h-screen {
        min-height: 100dvh; 
        height: auto !important;
        overflow: visible !important; 
    }

    #table-scroll-container {
        overflow-x: auto;
        overflow-y: visible !important; 
        -webkit-overflow-scrolling: touch;
    }
}

/* DESKTOP ONLY: Locked Background */
@media (min-width: 1024px) and (pointer: fine) {
    html, body {
        overflow: hidden !important; 
        height: 100vh;
        position: fixed;
        width: 100%;
    }

    .h-screen {
        height: 100vh !important;
        overflow: hidden;
    }

    #table-scroll-container {
        flex: 1;
        overflow: auto !important;
        min-height: 0; 
    }
}

/* --- 4. CRM TABLE & STICKY LOGIC --- */

#contact-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

/* Table Head: Always on top */
#table-head th {
    position: sticky !important;
    top: 0;
    z-index: 100 !important; 
    background-color: #f8fafc !important; 
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

/* Sticky Body Cells (Columns 1 & 2) */
.sticky-cell {
    position: sticky !important;
    background-color: white !important; 
    z-index: 20;
    background-clip: padding-box; 
    box-shadow: inset -1px 0 0 0 #e2e8f0; 
    overflow: visible !important; /* Allows buttons to remain clickable on top */
}

/* Corner Headers: The highest layer where stickies meet */
#table-head th.sticky-cell {
    z-index: 110 !important; 
    top: 0;
}

/* --- 5. ACTION BUTTON FIXES (THE "CLICK" FIX) --- */

/* This container matches the class in your JS actionBtnHtml string */
.action-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    position: relative;
    z-index: 150; /* Above the 1-100 table layers */
}

/* Force buttons to show the Hand cursor and ignore invisible overlaps */
.action-container button {
    position: relative !important;
    z-index: 160 !important; 
    cursor: pointer !important;
    pointer-events: auto !important;
    display: inline-flex !important;
    align-items: center;
}

/* Pass-through fix: Ensures Column 1 gap doesn't block Column 2 buttons */
.sticky-column-1 {
    pointer-events: none; 
}
.sticky-column-1 > * {
    pointer-events: auto; 
}

/* --- 6. OTHER CRM STYLES --- */

#render_table td {
    position: relative;
    z-index: 1;
}

[contenteditable="true"] {
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 120px;
}
[contenteditable="true"]:focus {
    background-color: #ffffff;
    box-shadow: inset 0 0 0 2px #3b82f6;
    border-radius: 4px;
    outline: none;
}

/* Modals Management */
#columnModal, #noteModal, #addClientModal {
    z-index: 99999 !important;
    position: fixed;
    inset: 0;
    display: none; 
}

#columnModal.show-flex, #noteModal.flex, #addClientModal.flex {
    display: flex !important;
}

#modalContainer {
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 1rem;
    width: 95%;
    max-width: 28rem;
    max-height: 85vh;
    overflow: hidden;
}

#columnList {
    flex: 1;
    overflow-y: auto !important;
    min-height: 0;
}

/* Custom Scrollbars */
.custom-scrollbar::-webkit-scrollbar, 
.overflow-x-auto::-webkit-scrollbar {
    height: 8px; width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-thumb, 
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
/* --- 6. MODAL MANAGEMENT (FINAL FIX) --- */

/* --- 6. MODAL MANAGEMENT --- */

/* Unified selector for all CRM modals */
#columnModal, #noteModal, #emailModal, #addClientModal {
    display: none !important; /* Truly gone when closed */
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important; /* Higher than sticky headers (60-110) */
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    pointer-events: none !important; /* Clicks pass through to the table below */
}

/* Unified 'Open' state triggered by JavaScript */
#columnModal.show-flex, 
#columnModal.flex,
#noteModal.flex, 
#emailModal.flex, 
#addClientModal.flex {
    display: flex !important;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important; /* Buttons become clickable */
}

/* Column Modal specific sizing */
#columnModalContainer {
    height: 500px;
    max-height: 85vh;
    min-height: 0;
}
/* Ensure Google Autocomplete dropdown is on top of everything */
.pac-container {
    z-index: 9999999 !important; 
    border-radius: 8px;
    margin-top: 2px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Fix for contenteditable relative positioning */
td[contenteditable="true"] {
    position: relative;
}

#sms-guide {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    background: #ffffff;
    border-left: 5px solid #16a34a; /* Green matching your SMS button */
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 280px;
    font-family: sans-serif;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.guide-step {
    margin-bottom: 10px;
    font-size: 13px;
    color: #374151;
}

.guide-step b {
    color: #059669;
}