/* ========================================================
   ADMISSION STRATEGIST PRO - PREMIUM B2B DESIGN SYSTEM
   ======================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5; 
    --primary-rgb: 79, 70, 229;
    --primary-dark: #3730a3;
    --bg: #f4f7f9; /* Slightly cooler gray for depth */
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-bg: #f8fafc;
    
    /* Semantic Colors */
    --safe: #10b981; 
    --safe-bg: #d1fae5;
    --risk: #f59e0b; 
    --risk-bg: #fef3c7;
    --miss: #ef4444;
    --miss-bg: #fee2e2;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    margin: 0;
    color: var(--text-main);
    padding-bottom: 100px;
    -webkit-font-smoothing: antialiased;
}

/* --- HERO SECTION --- */
.hero-section, .hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 3rem 1rem 5rem;
    text-align: center;
    margin-bottom: -4rem;
    box-shadow: inset 0 -10px 20px -10px rgba(0,0,0,0.3);
}
.hero-title, .hero h1 { font-size: 2.4rem; font-weight: 800; margin: 0 0 10px 0; letter-spacing: -0.02em; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.hero p, .hero div { font-size: 1.15rem; opacity: 0.9; font-weight: 500; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 2; }

/* --- PREMIUM CARDS --- */
.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 20px 25px -5px rgba(0, 0, 0, 0.08); /* Deep SaaS Shadow */
    border: 1px solid rgba(255,255,255,0.8);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card h3 { margin-top: 0; color: var(--text-main); font-size: 1.4rem; margin-bottom: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }

/* --- FORM ELEMENTS --- */
.form-grid, .grid-3-col, .compare-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-3-col { grid-template-columns: repeat(3, 1fr); }
.compare-grid { grid-template-columns: repeat(2, 1fr); }
.form-group { margin-bottom: 15px; position: relative; }

label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Universal Input Styles */
input[type="text"], input[type="number"], select {
    width: 100%; height: 48px;
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 16px;
    font-family: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text-main);
    transition: all 0.2s ease;
    box-sizing: border-box;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); /* Soft inner depth */
}

input:hover, select:hover { background-color: #f1f5f9; border-color: #cbd5e1; }
input:focus, select:focus {
    outline: none; background-color: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15), inset 0 2px 4px rgba(0,0,0,0.02);
}

/* FIX: Checkbox specific styling */
input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); margin: 0; display: inline-block; vertical-align: middle; }
.filter-opt { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 0.9rem; font-weight: 500;}

/* SELECT2 LIBRARY OVERRIDES */
.select2-container { width: 100% !important; }
.select2-container .select2-selection--single {
    height: 48px !important; background-color: var(--input-bg) !important;
    border: 1px solid var(--border) !important; border-radius: 10px !important;
    display: flex !important; align-items: center !important; transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-main) !important; font-weight: 600; padding-left: 16px !important; line-height: normal !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 46px !important; right: 10px !important; }
.select2-container--open .select2-selection--single {
    background-color: var(--surface) !important; border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15) !important;
}
.select2-dropdown { border: 1px solid var(--primary) !important; border-radius: 10px !important; box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important; overflow: hidden; }

/* --- PREMIUM BUTTONS --- */
.btn-submit, .btn {
    width: 100%; height: 50px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white; border: none; border-radius: 10px;
    font-weight: 800; font-size: 1.05rem; cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 15px rgba(var(--primary-rgb), 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    display: flex; justify-content: center; align-items: center; gap: 8px;
}
.btn-submit:hover, .btn:hover {
    transform: translateY(-2px); box-shadow: 0 12px 20px rgba(var(--primary-rgb), 0.4), inset 0 1px 0 rgba(255,255,255,0.2); filter: brightness(1.1);
}

.btn-download {
    background: white; color: var(--text-main);
    border: 1px solid var(--border); padding: 10px 18px; border-radius: 8px;
    font-weight: 700; font-size: 0.85rem; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: all 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.btn-download:hover { background: #f8fafc; border-color: #cbd5e1; box-shadow: 0 4px 6px rgba(0,0,0,0.06); }

.trend-btn { 
    background: linear-gradient(to bottom, #ffffff, #f8fafc); color: var(--primary);
    border: 1px solid var(--border); padding: 8px 16px; border-radius: 6px; font-size: 0.8rem; 
    cursor: pointer; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); white-space: nowrap;
}
.trend-btn:hover { border-color: var(--primary); background: #f8fafc; color: var(--primary-dark); transform: translateY(-1px); }

/* --- TABS --- */
.tabs { display: flex; justify-content: center; gap: 12px; margin-bottom: 30px; flex-wrap: wrap; }
.tab-btn {
    background: rgba(255,255,255,0.6); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.8); padding: 14px 28px; border-radius: 30px;
    font-weight: 700; cursor: pointer; color: #475569;
    display: flex; align-items: center; gap: 8px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); font-size: 1rem;
}
.tab-btn:hover { transform: translateY(-2px); background: #ffffff; color: var(--primary); }
.tab-btn.active {
    background: var(--surface); color: var(--primary); border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(var(--primary-rgb), 0.2); transform: translateY(-2px);
}
.tab-content { display: none; animation: fadeIn 0.4s ease-out; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- TABLES & RESULTS --- */
.results-container { display: flex; gap: 25px; align-items: flex-start; }
.filters-sidebar {
    width: 280px; flex-shrink: 0; background: var(--surface); padding: 25px;
    border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}
.results-content { flex-grow: 1; min-width: 0; }

.table-responsive { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; min-width: 800px; }
th {
    text-align: left; padding: 18px 16px; background: #f8fafc; color: #475569;
    font-size: 0.75rem; text-transform: uppercase; font-weight: 800; letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border); cursor: pointer; user-select: none; transition: background 0.2s;
}
th:hover:not(.sort-disabled) { background: #f1f5f9; color: var(--primary); }
td { padding: 18px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background-color: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* Sort Icons */
.sort-icon, th i { float: right; color: #cbd5e1; font-size: 0.9em; margin-left: 5px; opacity: 0.5; }
th:hover i { opacity: 1; }
th.sort-asc .sort-icon::after { content: "\f0de"; font-family: "Font Awesome 5 Free"; font-weight: 900; color: var(--primary); }
th.sort-desc .sort-icon::after { content: "\f0dd"; font-family: "Font Awesome 5 Free"; font-weight: 900; color: var(--primary); }
th:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: "\f0dc"; font-family: "Font Awesome 5 Free"; font-weight: 900; }

/* --- BADGES & AUDIT --- */
.audit-badge { padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; color: white; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.1);}
.bg-success { background-color: var(--safe); }
.bg-risk { background-color: var(--risk); }
.bg-fail { background-color: var(--miss); }
.bg-neutral { background-color: #94a3b8; }

/* JH NEET Specific Badges */
.badge-green { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-orange { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.badge-red { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-govt { display: inline-flex !important; width: max-content !important; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; padding: 4px 8px; font-size: 0.75rem; border-radius: 6px; font-weight: 700; margin-top: 6px; }

.badge-base { 
    padding: 6px 12px; 
    border-radius: 6px; 
    font-size: 0.75rem; 
    font-weight: 800;
    display: inline-block; 
    border: 1px solid transparent; 
    text-transform: uppercase; 
    white-space: nowrap; /* FIX: Forces text to stay on one line */
}
.user-choice-badge, .badge-pick {
    display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; 
    background: var(--safe-bg); color: var(--safe); padding: 4px 10px; border-radius: 12px; font-weight: 800; margin-top: 6px; border: 1px solid #a7f3d0;
}

/* --- MODALS & EXTRAS --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.7); backdrop-filter: blur(6px); }
.modal-content {
    background-color: var(--surface); margin: 5% auto; width: 90%; max-width: 800px;
    border-radius: 20px; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.3s ease-out;
}
.modal-header { padding: 20px 25px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.close-btn { font-size: 24px; cursor: pointer; color: var(--text-muted); transition: color 0.2s; font-weight: bold; }
.close-btn:hover { color: var(--miss); }

.drag-handle { cursor: grab; color: #cbd5e1; padding-right: 5px; font-size: 1.2rem; transition: color 0.2s; }
.drag-handle:hover { color: var(--primary); }
.serial-num { font-weight: 800; color: var(--primary); min-width: 25px; display: inline-block; text-align: center; background: rgba(var(--primary-rgb), 0.1); padding: 4px 8px; border-radius: 6px; }

.custom-order-banner {
    display: none; background-color: var(--risk-bg); border: 1px solid rgba(245, 158, 11, 0.4); color: #b45309; 
    padding: 15px 20px; border-radius: 12px; margin-bottom: 20px; font-size: 0.95rem; align-items: center; justify-content: space-between; animation: fadeIn 0.3s; font-weight: 500; box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.reset-sort-btn { background: var(--risk); color: white; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 800; transition: all 0.2s; box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3); }
.reset-sort-btn:hover { background: #d97706; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(245, 158, 11, 0.4); }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .hero-section, .hero { padding: 2rem 1rem 3rem; }
    .hero-title, .hero h1 { font-size: 1.8rem; }
    .container { padding: 0 10px; }
    .card { padding: 20px; border-radius: 12px; }
    .grid-3-col, .form-grid, .compare-grid { grid-template-columns: 1fr; gap: 15px; }
    .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 10px; justify-content: flex-start; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn { flex-shrink: 0; padding: 12px 18px; font-size: 0.9rem; }
    .results-container { flex-direction: column; }
    .filters-sidebar { width: 100%; margin-bottom: 20px; padding: 20px; box-sizing: border-box; }
    .modal-content { width: 95%; margin: 10% auto; }
}

/* ========================================================
   UI ALIGNMENT & SPACING PATCHES
   ======================================================== */

/* FIX A: Stop 'View' Button from touching the right table border */
table th:last-child, table td:last-child {
    padding-right: 25px !important;
}

/* FIX B: Un-scrunch the sidebar filters */
.filter-section {
    margin-bottom: 24px !important;
}
.filter-section label {
    margin-top: 18px !important; /* Pushes "College Type" away from text box */
    margin-bottom: 12px !important;
    font-size: 0.8rem;
    color: var(--text-main);
}
.filter-section:first-child label {
    margin-top: 0 !important; /* Keeps the top filter flush */
}

/* FIX C: Audit Report Alignment (Cutoffs bottom-left, Buttons far-right) */
.audit-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important; /* Centers probability & view button vertically */
    padding: 16px 20px !important;
    border-bottom: 1px solid var(--border) !important;
    gap: 20px;
}
.audit-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important; /* Puts cutoffs neatly below the college name */
    flex-grow: 1 !important;
    text-align: left !important;
}
.audit-text strong {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.4;
}
.audit-text small, .audit-text div {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.audit-actions {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex-shrink: 0 !important; /* Prevents button/badge from getting squished on small screens */
}


/* ========================================================
   PRINT / PDF EXPORT STYLES (COMPLETELY OVERHAULED)
   ======================================================== */
.print-only-header { display: none; }

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page { margin: 10mm; size: landscape; }

    /* WATERMARK FIX: Placed on top, fully visible, clicks pass through */
    body::after { 
        content: "JustCutoffs.com"; 
        position: fixed; 
        top: 50%; left: 50%; 
        transform: translate(-50%, -50%) rotate(-40deg); 
        font-size: 80px; 
        font-weight: 900; 
        color: rgba(0, 0, 0, 0.08) !important; 
        z-index: 9999 !important; 
        pointer-events: none;
        white-space: nowrap; 
    }
    
    /* HIDE ALL UI CLUTTER */
    .hero-section, .hero, .tabs, .filters-sidebar, .btn-submit, .btn, 
    .trend-btn, .user-choice-badge, .badge-pick, .btn-download, 
    .form-group, .select2, .custom-order-banner, .hide-on-print, .no-print,
    .collapsible-header, .collapsible-content,
    .card:has(form), /* Hides the form input section cleanly */
    .filter-input, input[type="text"], input[type="search"], /* CRITICAL: Hides the Cutoff Search bars */
    .search-container /* Hides any wrapper around the search */
    { 
        display: none !important; 
    }
    
    /* FORMAT THE REPORT HEADERS */
    .print-only-header { 
        display: block !important; 
        margin-bottom: 20px; 
        border-bottom: 2px solid #000; 
        padding-bottom: 10px; 
        page-break-after: avoid;
    }
    
    /* STRIP BACKGROUNDS FOR CLEAN PRINTING */
    body { background: white; color: black; }
    .container, .results-content, .card { 
        width: 100% !important; max-width: 100% !important; 
        padding: 0 !important; margin: 0 !important; 
        box-shadow: none !important; border: none !important; background: transparent !important;
    }
    
    /* AUDIT REPORT FIXES */
    .audit-item { 
        page-break-inside: avoid !important; 
        display: block !important; 
        border-bottom: 1px solid #ddd !important; 
        padding: 12px 0 !important; 
    }
    .audit-actions { 
        display: inline-block !important; 
        margin-top: 8px !important; 
    }

    /* TABLE FIXES: Force Table to fit perfectly on A4 Landscape */
    .results-container { display: block !important; width: 100% !important; }
    .table-responsive { 
        overflow: visible !important; 
        border: none !important; 
        box-shadow: none !important; 
        width: 100% !important; 
    }
    table { 
        width: 100% !important; 
        min-width: 100% !important; 
        font-size: 11px !important; 
        border-collapse: collapse !important; 
        table-layout: fixed !important; /* CRITICAL: Forces browser to respect widths */
        word-wrap: break-word !important; 
    }
    th, td { 
        padding: 8px 6px !important; 
        border: 1px solid #ccc !important; 
        white-space: normal !important; 
        overflow: hidden !important; 
        text-align: left !important;
        background: transparent !important; /* Prevents hiding the watermark */
    }
    
    /* Specific Column Widths to prevent cutoff */
    #stratTable th:nth-child(1), #stratTable td:nth-child(1),
    #bestTable th:nth-child(1), #bestTable td:nth-child(1) { width: 6%; } /* Pref */
    
    #stratTable th:nth-child(2), #stratTable td:nth-child(2),
    #bestTable th:nth-child(2), #bestTable td:nth-child(2) { width: 36%; } /* Institute */
    
    #stratTable th:nth-child(3), #stratTable td:nth-child(3),
    #bestTable th:nth-child(3), #bestTable td:nth-child(3) { width: 30%; } /* Branch */
    
    #stratTable th:nth-child(4), #stratTable td:nth-child(4),
    #bestTable th:nth-child(4), #bestTable td:nth-child(4) { width: 18%; } /* Cutoffs */
    
    #stratTable th:nth-child(5), #stratTable td:nth-child(5) { width: 10%; } /* Prob */
    
    tr { page-break-inside: avoid !important; }
    
    /* FORCE BADGE COLORS TO PRINT */
    .audit-badge { border: 1px solid #ccc; text-shadow: none !important; }
    .audit-badge.bg-success { color: #006400 !important; background: transparent !important; border-color: #006400 !important; }
    .audit-badge.bg-risk { color: #b45309 !important; background: transparent !important; border-color: #b45309 !important;}
    .audit-badge.bg-fail { color: #b91c1c !important; background: transparent !important; border-color: #b91c1c !important;}
}