<?php declare(strict_types=1);
/**
 * College2U — MBBS Admission Guide Bangalore
 * public_html/medical/mbbs-admission.php · v5.0.0 · May 2026
 *
 * Architecture: bootstrap.php → header.php → content → footer.php
 * Depth: 2 levels (public_html/medical/) → ../../php-portal/includes/
 *
 * SEO intent: "MBBS admission Bangalore 2026"
 * Schema: HowTo + FAQPage + EducationalOccupationalProgram + BreadcrumbList
 * Lead form: CSRF protected, rate-limited, inserts into leads table via c2u_submit_lead()
 */

// ── 1. Bootstrap ─────────────────────────────────────────────────────────────
require_once dirname(__DIR__) . '/includes/bootstrap.php';

// ── 2. Lead form handler ──────────────────────────────────────────────────────
$form_success = false;
$form_error   = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['c2u_mbbs_lead'])) {
    // Rate limit: 3 submissions per minute per IP
    if (!c2u_rate_limit('mbbs_lead_' . ($_SERVER['REMOTE_ADDR'] ?? 'x'), 3, 60)) {
        $form_error = 'Too many requests. Please try again in a minute.';
    } elseif (!c2u_csrf_valid()) {
        $form_error = 'Session expired. Please refresh the page and try again.';
    } else {
        $name     = trim($_POST['name']     ?? '');
        $phone    = trim($_POST['phone']    ?? '');
        $email    = trim($_POST['email']    ?? '');
        $neet_rank= trim($_POST['neet_rank'] ?? '');
        $category = trim($_POST['category'] ?? 'General');
        $quota    = trim($_POST['quota']    ?? 'Government');

        if ($name === '' || $phone === '') {
            $form_error = 'Please enter your name and mobile number.';
        } elseif (!c2u_valid_phone($phone)) {
            $form_error = 'Please enter a valid 10-digit Indian mobile number.';
        } else {
            $message = "NEET Rank: {$neet_rank} | Category: {$category} | Quota: {$quota}";
            $lead_id = c2u_submit_lead([
                'name'        => $name,
                'email'       => $email,
                'contact'     => $phone,
                'course'      => 'MBBS / UG Medical',
                'location'    => 'Bangalore',
                'message'     => $message,
                'source_page' => 'medical/mbbs-admission',
                'aria_heat'   => 40,
                'aria_intent' => 'HOT',
            ]);
            $form_success = ($lead_id > 0);
            if (!$form_success) {
                $form_error = 'Submission failed. Please call us at ' . C2U_PHONE . '.';
            }
        }
    }
}

// ── 3. Page data ──────────────────────────────────────────────────────────────
$current_year = (int) date('Y');

// Eligibility highlights (stagger grid)
$eligibility_points = [
    ['title' => 'Age',        'detail' => '17 years or older on or before December 31, ' . $current_year . '.', 'icon' => 'M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z'],
    ['title' => 'Academics',  'detail' => 'Passed 10+2 with Physics, Chemistry, and Biology — minimum 50% aggregate (40% for SC/ST/OBC).', 'icon' => 'M4 19.5A2.5 2.5 0 0 1 6.5 17H20'],
    ['title' => 'NEET-UG',   'detail' => 'Valid NEET-UG score in ' . $current_year . ' is mandatory for all medical courses in India.', 'icon' => 'M9 11l3 3L22 4M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 0 2 2h7'],
    ['title' => 'Nationality','detail' => 'Indian citizens, NRIs, OCIs, and foreign nationals are eligible under their respective quotas.', 'icon' => 'M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 0 0 1 1h3m10-11l2 2m-2-2v10a1 1 0 0 1-1 1h-3m-6 0a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1m-6 0h16'],
];

// Admission process steps (HowTo schema)
$howto_steps = [
    [1, 'Clear NEET-UG',
     'Appear in NEET-UG ' . $current_year . ' conducted by NTA. The exam is held once per year, usually in May. Download your scorecard from ntaresults.nic.in.',
     'https://nta.ac.in', 'NTA NEET portal'],

    [2, 'Register with KEA',
     'Register on the Karnataka Examinations Authority (KEA) portal at cetonline.karnataka.gov.in/kea. Upload documents: NEET scorecard, 10th/12th marks cards, category certificate (if applicable), Domicile/Income proof.',
     'https://kea.kar.nic.in', 'KEA portal'],

    [3, 'Fill College Choices',
     'During the choice-filling window, rank your preferred medical colleges in order of priority. Study past-year allotment data (available on College2U) before locking choices.',
     c2u_url('medical/top-medical-colleges'), 'View past allotment data'],

    [4, 'Seat Allotment',
     'KEA releases allotment results based on NEET rank, category, and choice-filling. Check your result on the KEA portal. If allotted, pay the seat acceptance fee within the deadline.',
     '', ''],

    [5, 'Confirm Admission & Report',
     'Carry original documents to the allotted college on the reporting date. Pay the first-year tuition fee. Document checklist: NEET scorecard, 10th/12th originals, transfer certificate, migration certificate, 10 passport photos, category certificate.',
     c2u_url('contact'), 'Get document checklist from College2U'],
];

// Fee comparison table
$fee_table = [
    ['quota' => 'Government Quota (KEA)', 'annual_fee' => '₹25,000 – ₹50,000', 'seats_pct' => '85%', 'process' => 'KEA counselling · NEET rank'],
    ['quota' => 'Management Quota (FFC)', 'annual_fee' => '≈ ₹13.5 lakh (FFC cap)', 'seats_pct' => '15%', 'process' => 'Direct / College admission'],
    ['quota' => 'NRI Quota',             'annual_fee' => '$15,000 – $25,000/yr',  'seats_pct' => '15% of private intake', 'process' => 'NRI sponsorship + NEET'],
];

// Top MBBS colleges
$mbbs_colleges = [
    ['name' => 'M S Ramaiah Medical College',                 'slug' => 'ms-ramaiah-medical-college',              'est' => 1979, 'govt_rank' => '~2,500',  'mgmt_rank' => '~40,000'],
    ['name' => 'Kempegowda Institute of Medical Sciences',    'slug' => 'kempegowda-institute-medical-sciences',   'est' => 1980, 'govt_rank' => '~4,000',  'mgmt_rank' => '~50,000'],
    ['name' => 'Bangalore Medical College &amp; RI',          'slug' => 'bangalore-medical-college-ri',            'est' => 1955, 'govt_rank' => '~800',    'mgmt_rank' => 'N/A (Govt)'],
    ['name' => 'St. John\'s Medical College',                 'slug' => 'st-johns-medical-college',                'est' => 1963, 'govt_rank' => '~2,000',  'mgmt_rank' => '~35,000'],
    ['name' => 'Vydehi Institute of Medical Sciences',        'slug' => 'vydehi-institute-medical-sciences',       'est' => 2002, 'govt_rank' => '~8,000',  'mgmt_rank' => '~60,000'],
    ['name' => 'The Oxford Medical College & RC',             'slug' => 'oxford-medical-college-bangalore',        'est' => 2013, 'govt_rank' => '~12,000', 'mgmt_rank' => '~70,000'],
];

// FAQs — AEO: direct declarative first sentence
$faqs = [
    ['q' => 'What NEET rank do I need for MBBS in Bangalore ' . $current_year . '?',
     'a' => 'A NEET-UG rank under 50,000 (General / EWS) qualifies you for most private MBBS colleges in Bangalore for ' . $current_year . '. Government colleges like BMCRI fill between ranks 500–5,000. MSRMC and Ramaiah fill at 15,000–35,000 in the KEA state merit allotment. Category candidates (SC/ST/OBC) may get admission at higher ranks under their reserved quota.'],
    ['q' => 'What is the MBBS fee in Bangalore private colleges ' . $current_year . '?',
     'a' => 'Management quota MBBS fees are capped by the Karnataka Fee Fixation Committee (FFC) at approximately ₹13.5 lakh per year for ' . $current_year . '. Government quota seats cost ₹25,000–₹50,000 annually. NRI quota fees are set individually by colleges and typically range from $15,000–$25,000 per year.'],
    ['q' => 'How many rounds does KEA MBBS counselling have in Karnataka?',
     'a' => 'KEA MBBS counselling for Karnataka state quota seats typically has 3 rounds: Round 1 (main allotment), Round 2 (first mop-up), and a final extended round for remaining vacant seats. After KEA rounds, colleges independently fill leftover management and NRI quota seats.'],
    ['q' => 'Can I get MBBS admission without NEET?',
     'a' => 'No. NEET-UG is mandatory for all MBBS admissions across India since 2020, as mandated by the Supreme Court and the National Medical Commission (NMC). There are no exceptions for private colleges or deemed universities in Karnataka.'],
    ['q' => 'Is there an age limit for MBBS admission ' . $current_year . '?',
     'a' => 'The minimum age for MBBS admission is 17 years, to be completed on or before December 31, ' . $current_year . '. The Supreme Court struck down the upper age limit of 25/30 years in 2018 — there is currently no maximum age cap for MBBS in India.'],
    ['q' => 'Which MBBS college in Bangalore has the lowest fees?',
     'a' => 'Bangalore Medical College and Research Institute (BMCRI), a government college, has the lowest MBBS fees at approximately ₹25,000–₹50,000 per year under government quota. Among private colleges, The Oxford Medical College and East Point Medical College have comparatively lower management quota fees.'],
];

// ── 4. SEO variables ──────────────────────────────────────────────────────────
$page_title       = 'MBBS Admission Bangalore ' . $current_year . ' — NEET Cutoff, Fees &amp; Counselling | College2U';
$meta_description = 'MBBS admission Bangalore ' . $current_year . ': NEET eligibility, KEA counselling rounds, government vs private fees, top colleges &amp; free expert shortlist.';
$canonical_path   = 'medical/mbbs-admission';
$body_class       = 'c2u-page c2u-page--admission c2u-page--mbbs';
$og_image         = c2u_asset('images/og/mbbs-admission-og.webp');
$schema_type      = 'MedicalWebPage';

$breadcrumbs = [
    ['name' => 'Medical', 'url' => c2u_url('medical')],
    ['name' => 'MBBS Admission ' . $current_year, 'url' => c2u_url('medical/mbbs-admission')],
];

// ── 5. Build schemas ──────────────────────────────────────────────────────────

// HowTo schema — NEET counselling process
$howto_schema = [
    '@context'    => 'https://schema.org',
    '@type'       => 'HowTo',
    'name'        => 'How to Get MBBS Admission in Bangalore ' . $current_year,
    'description' => 'Step-by-step guide to MBBS admission in Bangalore ' . $current_year . ' through KEA NEET counselling.',
    'totalTime'   => 'P4M',   // roughly 4 months from NEET to admission
    'step'        => array_map(fn($s) => [
        '@type'    => 'HowToStep',
        'position' => $s[0],
        'name'     => $s[1],
        'text'     => $s[2],
    ], $howto_steps),
];

// FAQPage schema
$faq_schema = [
    '@context'   => 'https://schema.org',
    '@type'      => 'FAQPage',
    'mainEntity' => array_map(fn($f) => [
        '@type'          => 'Question',
        'name'           => $f['q'],
        'acceptedAnswer' => ['@type' => 'Answer', 'text' => $f['a']],
    ], $faqs),
];

// EducationalOccupationalProgram
$program_schema = [
    '@context'              => 'https://schema.org',
    '@type'                 => 'EducationalOccupationalProgram',
    'name'                  => 'MBBS (Bachelor of Medicine, Bachelor of Surgery)',
    'description'           => 'A 5.5-year undergraduate medical degree programme requiring NEET-UG, offered at NMC-approved medical colleges in Bangalore, Karnataka.',
    'timeToComplete'        => 'P5Y6M',
    'programPrerequisites'  => 'NEET-UG qualification · 10+2 with PCB · Minimum 50% marks',
    'offers'                => [
        '@type'         => 'Offer',
        'priceCurrency' => 'INR',
        'price'         => '1350000',
        'description'   => 'Management quota per year — FFC cap ' . $current_year,
    ],
    'provider' => [
        '@type' => 'CollegeOrUniversity',
        'name'  => 'NMC-approved Medical Colleges in Bangalore',
        'address' => ['@type' => 'PostalAddress', 'addressLocality' => 'Bangalore', 'addressRegion' => 'Karnataka', 'addressCountry' => 'IN'],
    ],
];

$extra_schemas = [
    c2u_schema_breadcrumb($breadcrumbs),
    $howto_schema,
    $faq_schema,
    $program_schema,
];

// ── 6. Extra head: CSS + hero image preload ───────────────────────────────────
$extra_head = '<link rel="preload" as="image" href="' . c2u_e(c2u_asset('images/banners/mbbs-hero.webp')) . '" fetchpriority="high">
<style nonce="' . c2u_e(C2U_CSP_NONCE) . '">
:root{
  --red:#ef4444;--red-dark:#dc2626;--red-light:#fef2f2;--red-mid:#fee2e2;
  --surface:#f8fafc;--border:#e2e8f0;
  --text:#0f172a;--muted:#64748b;
  --radius:1rem;--shadow:0 4px 24px rgba(0,0,0,.09);
}

/* ── Admission hero ──────────────────────────────────────────────────────── */
.adm-hero{
  background:linear-gradient(145deg,#1a0505 0%,#3b0a0a 100%);
  min-height:min(55vh,480px);display:flex;align-items:center;
  overflow:hidden;position:relative;isolation:isolate;
}
.adm-hero__bg{
  position:absolute;inset:0;
  background-image:url("/assets/images/banners/mbbs-hero.webp");
  background-size:cover;background-position:center 30%;
  opacity:.18;z-index:-1;
}
.adm-hero__inner{
  width:100%;max-width:1200px;margin:0 auto;padding:3.5rem 1.5rem;
  display:grid;grid-template-columns:1fr min(400px,40%);gap:2.5rem;align-items:center;
}
@media(max-width:840px){.adm-hero__inner{grid-template-columns:1fr;}}
.adm-eyebrow{
  display:inline-flex;align-items:center;gap:.5rem;
  background:rgba(239,68,68,.2);border:1px solid rgba(239,68,68,.4);
  color:#fca5a5;border-radius:2rem;
  padding:.375rem .875rem;font-size:.8rem;font-weight:600;
  letter-spacing:.04em;text-transform:uppercase;margin-bottom:1rem;
}
.adm-h1{
  font-size:clamp(1.75rem,4vw,2.75rem);font-weight:800;
  color:#fff;letter-spacing:-.025em;margin:0 0 .5rem;line-height:1.15;
}
.adm-h1 em{color:#fca5a5;font-style:normal;}
.adm-sub-tags{display:flex;flex-wrap:wrap;gap:.5rem;margin:.75rem 0 1.5rem;}
.adm-tag{
  background:rgba(255,255,255,.12);color:rgba(255,255,255,.8);
  border-radius:2rem;padding:.3rem .75rem;font-size:.8rem;font-weight:500;
}
.adm-ctas{display:flex;flex-wrap:wrap;gap:.75rem;}
.btn-primary{
  background:var(--red);color:#fff;font-weight:700;font-size:.9375rem;
  padding:.75rem 1.75rem;border-radius:.5rem;border:none;cursor:pointer;
  text-decoration:none;display:inline-flex;align-items:center;gap:.5rem;
  transition:background .2s,transform .15s;
}
.btn-primary:hover{background:var(--red-dark);transform:translateY(-1px);}
.btn-secondary{
  background:rgba(255,255,255,.1);color:#fff;font-weight:600;font-size:.9375rem;
  padding:.75rem 1.75rem;border-radius:.5rem;
  border:1px solid rgba(255,255,255,.25);text-decoration:none;
  transition:background .2s;display:inline-flex;align-items:center;gap:.5rem;
}
.btn-secondary:hover{background:rgba(255,255,255,.18);}

/* Lead form in hero */
.adm-form-card{
  background:#fff;border-radius:var(--radius);padding:1.75rem;
  box-shadow:0 8px 40px rgba(0,0,0,.2);
}
.adm-form-card h2{font-size:1.0625rem;font-weight:700;color:var(--text);margin:0 0 .25rem;}
.adm-form-card p{font-size:.8125rem;color:var(--muted);margin:0 0 1.25rem;}
.fg{margin-bottom:.875rem;}
.fg label{display:block;font-size:.8125rem;font-weight:600;color:var(--text);margin-bottom:.35rem;}
.fg input,.fg select{
  width:100%;padding:.625rem .875rem;
  border:1.5px solid var(--border);border-radius:.5rem;
  font-size:.9rem;color:var(--text);background:#fff;
  transition:border-color .2s,box-shadow .2s;box-sizing:border-box;
}
.fg input:focus,.fg select:focus{outline:none;border-color:#ef4444;box-shadow:0 0 0 3px rgba(239,68,68,.15);}
.fg select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'12\' height=\'8\' viewBox=\'0 0 12 8\'%3E%3Cpath d=\'M1 1l5 5 5-5\' stroke=\'%2364748b\' stroke-width=\'1.5\' fill=\'none\' stroke-linecap=\'round\'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right .875rem center;}
.btn-form-submit{
  width:100%;background:var(--text);color:#fff;font-weight:700;font-size:.9375rem;
  padding:.75rem;border-radius:.5rem;border:none;cursor:pointer;
  transition:background .2s,transform .15s;margin-top:.25rem;
}
.btn-form-submit:hover{background:#1e3a5f;transform:translateY(-1px);}
.form-success{background:#ecfdf5;border:1px solid #a7f3d0;border-radius:.5rem;padding:1rem;color:#065f46;font-weight:600;text-align:center;}
.form-error{background:var(--red-light);border:1px solid #fca5a5;border-radius:.5rem;padding:.625rem 1rem;color:#991b1b;font-size:.875rem;margin-bottom:.75rem;}

/* ── Shared section ──────────────────────────────────────────────────────── */
.c2u-section{padding:4rem 1.5rem;}
.c2u-section--alt{background:var(--surface);}
.c2u-section-inner{max-width:1200px;margin:0 auto;}
.c2u-section-heading{
  font-size:clamp(1.375rem,3vw,2rem);font-weight:800;color:var(--text);
  letter-spacing:-.025em;margin:0 0 .5rem;
}
.c2u-section-heading em{color:var(--red-dark);font-style:normal;}
.c2u-section-sub{font-size:.9375rem;color:var(--muted);margin:0 0 2.5rem;line-height:1.6;max-width:600px;}

/* ── Eligibility grid ────────────────────────────────────────────────────── */
.highlight-row{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:1.25rem;
}
.highlight-box{
  background:#fff;border:1.5px solid var(--border);border-radius:var(--radius);
  padding:1.5rem;position:relative;overflow:hidden;
}
.highlight-box::before{
  content:\'\';position:absolute;top:0;left:0;right:0;height:3px;
  background:linear-gradient(90deg,var(--red),var(--red-dark));
}
.hb-icon{
  width:44px;height:44px;background:var(--red-light);border-radius:.625rem;
  display:flex;align-items:center;justify-content:center;
  color:var(--red-dark);margin-bottom:1rem;
}
.hb-title{font-size:.9375rem;font-weight:700;color:var(--text);margin:0 0 .375rem;}
.hb-detail{font-size:.875rem;color:var(--muted);line-height:1.55;margin:0;}

/* ── HowTo steps ─────────────────────────────────────────────────────────── */
.howto-list{display:flex;flex-direction:column;gap:0;max-width:840px;}
.timeline-item{
  display:grid;grid-template-columns:48px 1fr;gap:1.25rem;
  padding:1.5rem 0;border-bottom:1px solid var(--border);position:relative;
}
.timeline-item:last-child{border-bottom:none;}
.tl-num{
  width:40px;height:40px;border-radius:50%;
  background:var(--text);color:#fff;font-weight:800;font-size:.9375rem;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.tl-content{}
.tl-title{font-size:1rem;font-weight:700;color:var(--text);margin:0 0 .5rem;}
.tl-desc{font-size:.9rem;color:var(--muted);line-height:1.6;margin:0 0 .75rem;}
.tl-link{font-size:.8125rem;font-weight:600;color:var(--red-dark);text-decoration:none;}
.tl-link:hover{text-decoration:underline;}

/* ── Fee table ───────────────────────────────────────────────────────────── */
.fee-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin-top:1.5rem;}
.fee-table{width:100%;border-collapse:collapse;font-size:.9rem;}
.fee-table th{
  text-align:left;padding:.75rem 1rem;
  font-size:.8rem;font-weight:700;color:var(--muted);
  letter-spacing:.04em;text-transform:uppercase;
  border-bottom:2px solid var(--border);background:var(--surface);
}
.fee-table td{padding:.875rem 1rem;border-bottom:1px solid var(--border);color:var(--text);}
.fee-table tr:last-child td{border-bottom:none;}
.fee-table tr:hover td{background:#fafafa;}
.fee-highlight{font-weight:700;color:var(--red-dark);}

/* ── College grid ────────────────────────────────────────────────────────── */
.college-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(300px,1fr));
  gap:1.125rem;
}
.college-card{
  background:#fff;border:1.5px solid var(--border);border-radius:var(--radius);
  padding:1.25rem;display:flex;align-items:flex-start;gap:.875rem;
  transition:border-color .2s,box-shadow .2s;
}
.college-card:hover{border-color:var(--red);box-shadow:var(--shadow);}
.college-logo{width:48px;height:48px;flex-shrink:0;}
.college-meta{flex:1;min-width:0;}
.college-name{font-size:.9375rem;font-weight:700;color:var(--text);margin:0 0 .375rem;line-height:1.3;}
.college-cutoff{font-size:.8125rem;color:var(--muted);margin:0 0 .25rem;}
.college-cutoff strong{color:var(--red-dark);}

/* ── FAQ ─────────────────────────────────────────────────────────────────── */
.faq-list{max-width:800px;}
.faq-item{border-bottom:1px solid var(--border);}
.faq-q{
  width:100%;display:flex;justify-content:space-between;align-items:center;
  background:none;border:none;cursor:pointer;padding:1.125rem 0;
  font-size:.9375rem;font-weight:600;color:var(--text);text-align:left;gap:1rem;
}
.faq-q__icon{flex-shrink:0;transition:transform .25s;color:var(--muted);}
.faq-q[aria-expanded="true"] .faq-q__icon{transform:rotate(180deg);}
.faq-a{padding:0 0 1.125rem;font-size:.9375rem;line-height:1.65;color:var(--muted);}
.faq-a[hidden]{display:none;}

/* ── CTA banner ──────────────────────────────────────────────────────────── */
.cta-banner{
  background:linear-gradient(135deg,var(--red-light),var(--red-mid));
  border:1.5px solid #fca5a5;border-radius:var(--radius);
  padding:2.5rem;display:flex;flex-wrap:wrap;
  align-items:center;justify-content:space-between;gap:1.5rem;margin-top:3rem;
}
.cta-banner h2{font-size:1.25rem;font-weight:800;color:#7f1d1d;margin:0;}
.cta-banner p{font-size:.9375rem;color:#991b1b;margin:.25rem 0 0;}
.btn-cta{
  background:var(--red);color:#fff;font-weight:700;font-size:.9375rem;
  padding:.75rem 1.75rem;border-radius:.5rem;border:none;cursor:pointer;
  text-decoration:none;white-space:nowrap;transition:background .2s;flex-shrink:0;
}
.btn-cta:hover{background:var(--red-dark);}

/* ── Sidebar card ────────────────────────────────────────────────────────── */
.sidebar-card{
  background:#fff;border:1.5px solid var(--border);border-radius:var(--radius);
  padding:1.5rem;position:sticky;top:80px;
}
.sidebar-card h3{font-size:.9375rem;font-weight:700;color:var(--text);margin:0 0 1rem;}
.sidebar-links{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:.5rem;}
.sidebar-links a{
  font-size:.875rem;color:var(--red-dark);text-decoration:none;
  display:flex;align-items:center;gap:.5rem;font-weight:500;
}
.sidebar-links a:hover{text-decoration:underline;}

/* ── Two-column layout for long sections ────────────────────────────────── */
.content-with-sidebar{
  display:grid;grid-template-columns:1fr 300px;gap:2.5rem;align-items:start;
}
@media(max-width:900px){.content-with-sidebar{grid-template-columns:1fr;}}
@media(max-width:600px){
  .highlight-row{grid-template-columns:1fr;}
  .college-grid{grid-template-columns:1fr;}
}
</style>';

// Page JS — FAQ accordion (no inline handlers)
$page_js = <<<'JS'
(function(){
  document.querySelectorAll('.faq-q').forEach(function(btn){
    btn.addEventListener('click',function(){
      var expanded=this.getAttribute('aria-expanded')==='true';
      document.querySelectorAll('.faq-q').forEach(function(b){
        b.setAttribute('aria-expanded','false');
        var p=document.getElementById(b.getAttribute('aria-controls'));
        if(p){p.hidden=true;}
      });
      if(!expanded){
        this.setAttribute('aria-expanded','true');
        var panel=document.getElementById(this.getAttribute('aria-controls'));
        if(panel){panel.hidden=false;}
      }
    });
  });
})();
JS;

// ── 7. Header ─────────────────────────────────────────────────────────────────
require_once C2U_INCLUDES . '/header.php';
?>

<!-- ══════════════════════════════════════════════════════════════════════════
     ADMISSION HERO
     H1: MBBS Admission in Bangalore 2026
     Subtitle: qualifiers delivered as <p>, not H2 — preserves heading hierarchy
══════════════════════════════════════════════════════════════════════════════ -->
<section class="adm-hero" aria-labelledby="adm-h1">
  <div class="adm-hero__bg" role="presentation" aria-hidden="true"></div>

  <div class="adm-hero__inner">
    <!-- Left: heading + intro -->
    <div class="adm-hero__left">
      <!-- Breadcrumb -->
      <nav aria-label="Breadcrumb" style="margin-bottom:1rem;">
        <ol style="list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;align-items:center;gap:.4rem;font-size:.8125rem;color:rgba(255,255,255,.5);">
          <li><a href="<?= c2u_e(c2u_url('')) ?>" style="color:rgba(255,255,255,.5);text-decoration:none;">Home</a></li>
          <li aria-hidden="true" style="color:rgba(255,255,255,.3);">/</li>
          <li><a href="<?= c2u_e(c2u_url('medical')) ?>" style="color:rgba(255,255,255,.5);text-decoration:none;">Medical</a></li>
          <li aria-hidden="true" style="color:rgba(255,255,255,.3);">/</li>
          <li aria-current="page" style="color:rgba(255,255,255,.8);">MBBS Admission <?= $current_year ?></li>
        </ol>
      </nav>

      <p class="adm-eyebrow">
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>
        NEET · KEA · MCC · COMED-K <?= $current_year ?>
      </p>

      <h1 class="adm-h1" id="adm-h1">
        MBBS Admission in <em>Bangalore</em> <?= $current_year ?>
      </h1>

      <!-- Qualifier tags — NOT an H2 to preserve heading structure -->
      <div class="adm-sub-tags" role="list" aria-label="Admission pathways">
        <?php foreach (['NEET-UG Required', 'Government &amp; Private', 'KEA Counselling', 'Management Quota', 'NRI Quota'] as $tag): ?>
        <span class="adm-tag" role="listitem"><?= $tag ?></span>
        <?php endforeach; ?>
      </div>

      <div class="adm-ctas">
        <a href="#howto" class="btn-primary">
          <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true" focusable="false"><polyline points="9 18 15 12 9 6"/></svg>
          Admission process →
        </a>
        <a href="<?= c2u_e(c2u_url('counselor-booking')) ?>" class="btn-secondary">
          Book free counselling
        </a>
      </div>
    </div>

    <!-- Right: lead form -->
    <aside class="adm-hero__right" aria-label="MBBS admission enquiry form">
      <div class="adm-form-card">
        <h2>Get MBBS shortlist for your rank</h2>
        <p>Counsellors call back within 2 hours.</p>

        <?php if ($form_success): ?>
          <div class="form-success" role="alert">
            <strong>We'll call you soon!</strong><br>
            Your MBBS counsellor will reach you within 2 hours.
          </div>
        <?php else: ?>
          <?php if ($form_error): ?>
            <p class="form-error" role="alert"><?= c2u_e($form_error) ?></p>
          <?php endif; ?>

          <form method="POST"
                action="<?= c2u_e(c2u_url('medical/mbbs-admission')) ?>#adm-form"
                id="adm-form"
                novalidate>
            <?= c2u_csrf_field() ?>
            <input type="hidden" name="c2u_mbbs_lead" value="1">

            <div class="fg">
              <label for="mbbs-name">Full name <span aria-hidden="true">*</span></label>
              <input type="text" id="mbbs-name" name="name"
                     placeholder="e.g. Arjun Reddy"
                     value="<?= c2u_e($_POST['name'] ?? '') ?>"
                     autocomplete="name" required aria-required="true">
            </div>

            <div class="fg">
              <label for="mbbs-phone">Mobile number <span aria-hidden="true">*</span></label>
              <input type="tel" id="mbbs-phone" name="phone"
                     placeholder="10-digit number"
                     value="<?= c2u_e($_POST['phone'] ?? '') ?>"
                     autocomplete="tel" required aria-required="true" maxlength="13">
            </div>

            <div class="fg">
              <label for="mbbs-neet">NEET <?= $current_year ?> rank (approximate)</label>
              <input type="text" id="mbbs-neet" name="neet_rank"
                     placeholder="e.g. 25000"
                     value="<?= c2u_e($_POST['neet_rank'] ?? '') ?>"
                     inputmode="numeric">
            </div>

            <div class="fg">
              <label for="mbbs-category">Category</label>
              <select id="mbbs-category" name="category">
                <?php foreach (['General','OBC','SC','ST','EWS'] as $cat): ?>
                <option value="<?= c2u_e($cat) ?>"<?= (($_POST['category'] ?? '') === $cat) ? ' selected' : '' ?>><?= c2u_e($cat) ?></option>
                <?php endforeach; ?>
              </select>
            </div>

            <div class="fg">
              <label for="mbbs-quota">Preferred quota</label>
              <select id="mbbs-quota" name="quota">
                <?php foreach (['Government Quota','Management Quota','NRI Quota','Any'] as $q): ?>
                <option value="<?= c2u_e($q) ?>"<?= (($_POST['quota'] ?? '') === $q) ? ' selected' : '' ?>><?= c2u_e($q) ?></option>
                <?php endforeach; ?>
              </select>
            </div>

            <button type="submit" class="btn-form-submit">
              Get free MBBS shortlist →
            </button>
          </form>
        <?php endif; ?>

        <p style="font-size:.75rem;color:#94a3b8;text-align:center;margin:.75rem 0 0;">
          Free service. No referral fees. No spam.
        </p>
      </div>
    </aside>
  </div>
</section>

<!-- ══════════════════════════════════════════════════════════════════════════
     ELIGIBILITY SECTION
     H2: What is the eligibility for MBBS in Bangalore 2026?
     → AEO: direct answer in the first sentence of each box
══════════════════════════════════════════════════════════════════════════════ -->
<section class="c2u-section" id="eligibility" aria-labelledby="elig-h2">
  <div class="c2u-section-inner">
    <header style="margin-bottom:2.5rem;">
      <h2 class="c2u-section-heading" id="elig-h2">
        What is the eligibility for MBBS in Bangalore <?= $current_year ?>?
      </h2>
      <p class="c2u-section-sub">
        All four criteria below are mandatory. Missing any one disqualifies a candidate regardless of NEET score.
      </p>
    </header>

    <!-- data-animate="stagger" → college2u-lazy.js applies staggered fade-up -->
    <div class="highlight-row" data-animate="stagger" role="list">
      <?php foreach ($eligibility_points as $ep): ?>
      <div class="highlight-box" role="listitem">
        <div class="hb-icon" aria-hidden="true">
          <svg width="22" height="22" viewBox="0 0 24 24" fill="none"
               stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
            <path d="<?= c2u_e($ep['icon']) ?>"/>
          </svg>
        </div>
        <h3 class="hb-title"><?= c2u_e($ep['title']) ?></h3>
        <p class="hb-detail"><?= c2u_e($ep['detail']) ?></p>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- ══════════════════════════════════════════════════════════════════════════
     HOW NEET COUNSELLING WORKS
     H2: How does NEET counselling work for MBBS in Karnataka?
     → HowTo schema driven — step-by-step process
══════════════════════════════════════════════════════════════════════════════ -->
<section class="c2u-section c2u-section--alt" id="howto" aria-labelledby="howto-h2">
  <div class="c2u-section-inner content-with-sidebar">
    <!-- Main content -->
    <div>
      <header style="margin-bottom:2rem;">
        <h2 class="c2u-section-heading" id="howto-h2" data-aeo-speakable>
          How does NEET counselling work for <abbr title="Bachelor of Medicine, Bachelor of Surgery">MBBS</abbr> in Karnataka?
        </h2>
        <p class="c2u-section-sub">
          From clearing NEET to sitting in your first lecture — here are the five steps for
          MBBS admission in Bangalore <?= $current_year ?>.
        </p>
      </header>

      <!-- Timeline steps — .timeline-item is auto-picked up by college2u-lazy.js -->
      <ol class="howto-list" aria-label="MBBS admission steps <?= $current_year ?>">
        <?php foreach ($howto_steps as [$num, $title, $desc, $href, $linkLabel]): ?>
        <li class="timeline-item">
          <div class="tl-num" aria-label="Step <?= $num ?>"><?= $num ?></div>
          <div class="tl-content">
            <h3 class="tl-title"><?= c2u_e($title) ?></h3>
            <p class="tl-desc"><?= c2u_e($desc) ?></p>
            <?php if ($href): ?>
            <a href="<?= c2u_e($href) ?>" class="tl-link"
               <?= (str_starts_with($href, 'http') ? 'rel="noopener noreferrer" target="_blank"' : '') ?>>
              <?= c2u_e($linkLabel) ?> →
            </a>
            <?php endif; ?>
          </div>
        </li>
        <?php endforeach; ?>
      </ol>
    </div>

    <!-- Sidebar -->
    <aside aria-label="Quick links — MBBS admission">
      <div class="sidebar-card">
        <h3>Quick links</h3>
        <ul class="sidebar-links">
          <li><a href="<?= c2u_e(c2u_url('medical')) ?>">← Back to Medical stream hub</a></li>
          <li><a href="<?= c2u_e(c2u_url('medical/top-medical-colleges')) ?>">Top medical colleges in Bangalore</a></li>
          <li><a href="<?= c2u_e(c2u_url('medical/dental-admission')) ?>">Dental (BDS) admission guide</a></li>
          <li><a href="<?= c2u_e(c2u_url('medical/ayurveda-admission')) ?>">BAMS admission guide</a></li>
          <li><a href="<?= c2u_e(c2u_url('exams')) ?>">NEET <?= $current_year ?> exam guide</a></li>
          <li><a href="<?= c2u_e(c2u_url('nri-quota')) ?>">NRI quota guide</a></li>
          <li><a href="<?= c2u_e(c2u_url('counselor-booking')) ?>">Book free counselling</a></li>
        </ul>
      </div>
    </aside>
  </div>
</section>

<!-- ══════════════════════════════════════════════════════════════════════════
     FEE COMPARISON
     H2: Government vs private MBBS fees in Bangalore 2026
══════════════════════════════════════════════════════════════════════════════ -->
<section class="c2u-section" id="fees" aria-labelledby="fees-h2">
  <div class="c2u-section-inner" style="max-width:900px;">
    <header style="margin-bottom:1.5rem;">
      <h2 class="c2u-section-heading" id="fees-h2">
        Government vs private MBBS fees in Bangalore <?= $current_year ?>
      </h2>
      <p class="c2u-section-sub">
        Management quota fees are regulated by the Karnataka <abbr title="Fee Fixation Committee">FFC</abbr>.
        Government quota fees are set by the state government.
      </p>
    </header>

    <div class="fee-table-wrap">
      <table class="fee-table" aria-label="MBBS fee comparison Bangalore <?= $current_year ?>">
        <thead>
          <tr>
            <th scope="col">Quota</th>
            <th scope="col">Annual fee (<?= $current_year ?>)</th>
            <th scope="col">Seat share</th>
            <th scope="col">Admission process</th>
          </tr>
        </thead>
        <tbody>
          <?php foreach ($fee_table as $row): ?>
          <tr>
            <td style="font-weight:600;"><?= c2u_e($row['quota']) ?></td>
            <td class="fee-highlight"><?= c2u_e($row['annual_fee']) ?></td>
            <td><?= c2u_e($row['seats_pct']) ?></td>
            <td style="font-size:.875rem;color:#64748b;"><?= c2u_e($row['process']) ?></td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    </div>

    <p style="margin-top:1rem;font-size:.8125rem;color:#94a3b8;">
      * FFC = Karnataka Fee Fixation Committee. Management quota fee cap is reviewed annually.
      NRI quota fees are in USD as set by individual institutions and are not FFC-regulated.
    </p>
  </div>
</section>

<!-- ══════════════════════════════════════════════════════════════════════════
     TOP MBBS COLLEGES
     H2: Top MBBS colleges in Bangalore — NEET cutoffs 2025–26
══════════════════════════════════════════════════════════════════════════════ -->
<section class="c2u-section c2u-section--alt" id="colleges" aria-labelledby="colleges-h2">
  <div class="c2u-section-inner">
    <header style="margin-bottom:2rem;display:flex;justify-content:space-between;align-items:flex-end;flex-wrap:wrap;gap:1rem;">
      <div>
        <h2 class="c2u-section-heading" id="colleges-h2">
          Top <abbr title="Bachelor of Medicine, Bachelor of Surgery">MBBS</abbr> colleges in Bangalore — NEET cutoffs <?= $current_year - 1 ?>–<?= substr((string)$current_year, 2) ?>
        </h2>
        <p style="font-size:.875rem;color:#64748b;margin:.25rem 0 0;">
          NEET rank at last allotted seat in KEA counselling <?= $current_year - 1 ?>. Verify at <a href="https://kea.kar.nic.in" rel="noopener noreferrer" target="_blank" style="color:var(--red-dark);">kea.kar.nic.in</a>.
        </p>
      </div>
      <a href="<?= c2u_e(c2u_url('medical/top-medical-colleges')) ?>"
         style="font-size:.875rem;font-weight:600;color:var(--red-dark);text-decoration:none;white-space:nowrap;">
        View all colleges →
      </a>
    </header>

    <!-- data-animate="stagger" — card stagger animation -->
    <div class="college-grid" data-animate="stagger" role="list">
      <?php foreach ($mbbs_colleges as $col): ?>
      <div class="college-card" role="listitem">
        <div class="college-logo" aria-hidden="true">
          <?= logoHtml($col['name'], $col['slug'], 'College2U', 48) ?>
        </div>
        <div class="college-meta">
          <h3 class="college-name"><?= c2u_e($col['name']) ?></h3>
          <p class="college-cutoff">
            Govt quota cutoff: <strong><?= c2u_e($col['govt_rank']) ?></strong>
          </p>
          <p class="college-cutoff">
            Mgmt quota cutoff: <strong><?= c2u_e($col['mgmt_rank']) ?></strong>
          </p>
          <a href="<?= c2u_e(c2u_url('college/' . $col['slug'])) ?>"
             style="font-size:.8125rem;font-weight:600;color:var(--red-dark);text-decoration:none;">
            Full profile →
          </a>
        </div>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- ══════════════════════════════════════════════════════════════════════════
     FAQ SECTION
     AEO: direct declarative answers throughout
══════════════════════════════════════════════════════════════════════════════ -->
<section class="c2u-section" id="faq" aria-labelledby="faq-h2">
  <div class="c2u-section-inner">
    <header style="margin-bottom:2.5rem;">
      <h2 class="c2u-section-heading" id="faq-h2">
        MBBS Admission Bangalore <?= $current_year ?> — Frequently Asked Questions
      </h2>
      <p class="c2u-section-sub">
        Answers sourced from NTA, KEA, NMC, and Karnataka FFC official documents.
      </p>
    </header>

    <div class="faq-list" role="list">
      <?php foreach ($faqs as $i => $faq): ?>
      <div class="faq-item" role="listitem">
        <button class="faq-q"
                id="bfaq-btn-<?= $i ?>"
                type="button"
                aria-expanded="false"
                aria-controls="bfaq-a-<?= $i ?>">
          <span><?= c2u_e($faq['q']) ?></span>
          <span class="faq-q__icon" aria-hidden="true">
            <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M4 6l5 5 5-5"/></svg>
          </span>
        </button>
        <div class="faq-a"
             id="bfaq-a-<?= $i ?>"
             role="region"
             aria-labelledby="bfaq-btn-<?= $i ?>"
             data-aeo-speakable
             hidden>
          <p><?= c2u_e($faq['a']) ?></p>
        </div>
      </div>
      <?php endforeach; ?>
    </div>

    <!-- CTA banner -->
    <div class="cta-banner" role="complementary" aria-label="Get personalised MBBS guidance">
      <div>
        <h2>Get a free MBBS college shortlist for <?= $current_year ?></h2>
        <p>Based on your NEET rank, category, and fee budget — from College2U counsellors.</p>
      </div>
      <a href="<?= c2u_e(c2u_url('counselor-booking')) ?>" class="btn-cta">
        Book free counselling →
      </a>
    </div>

    <!-- Internal link cluster — SEO -->
    <nav aria-label="Related MBBS and medical admission guides" style="margin-top:3rem;">
      <h3 style="font-size:.8125rem;font-weight:700;color:#94a3b8;letter-spacing:.04em;text-transform:uppercase;margin:0 0 1rem;">
        You might also need
      </h3>
      <ul style="list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:.5rem;">
        <?php
        $related = [
            ['Top Medical Colleges Bangalore',               c2u_url('medical/top-medical-colleges')],
            ['Dental (BDS) Admission Bangalore ' . $current_year, c2u_url('medical/dental-admission')],
            ['BAMS Admission Karnataka ' . $current_year,   c2u_url('medical/ayurveda-admission')],
            ['NEET Cutoff Karnataka ' . $current_year,      c2u_url('exams')],
            ['NRI Quota MBBS Guide',                        c2u_url('nri-quota')],
            ['Management Quota MBBS Karnataka',             c2u_url('medical')],
            ['All Medical Colleges Bangalore',              c2u_url('colleges')],
        ];
        foreach ($related as [$label, $href]): ?>
        <li>
          <a href="<?= c2u_e($href) ?>"
             style="display:inline-block;padding:.35rem .8rem;background:#fff;
                    border:1.5px solid #e2e8f0;border-radius:2rem;
                    font-size:.8rem;font-weight:600;color:#374151;
                    text-decoration:none;"><?= c2u_e($label) ?></a>
        </li>
        <?php endforeach; ?>
      </ul>
    </nav>
  </div>
</section>

<?php require_once C2U_INCLUDES . '/footer.php'; ?>
