/* ============================================
   MPYPCP - MOBILE-FIRST RESPONSIVE FOUNDATION
   Zero horizontal overflow, app-like mobile UI
   ============================================ */

/* ============================================
   STEP 1: GLOBAL FOUNDATION
   ============================================ */

/* Box-sizing reset for all elements */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Prevent horizontal overflow */
html {
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
    margin: 0;
    padding: 0;
}

/* Responsive media elements */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent content images from causing overflow - exclude logos/icons */
section img,
.course-img img,
.content img,
.motivation-section img,
.highlights-section img,
.benefits-section img,
.review-card img,
.alumni-section img {
    width: 100%;
    object-fit: cover;
}

/* Container: defined in layout-system.css; mobile base here for load order */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ============================================
   STEP 2: MOBILE-FIRST BREAKPOINTS
   Base: 0-479px (phones)
   sm: 480-767px (large phones)
   md: 768-1023px (tablets)
   lg: 1024px+ (desktop)
   ============================================ */

/* Base styles (mobile-first) - 0-479px */
:root {
    --spacing-xs: clamp(8px, 2vw, 12px);
    --spacing-sm: clamp(12px, 3vw, 16px);
    --spacing-md: clamp(16px, 4vw, 24px);
    --spacing-lg: clamp(24px, 6vw, 40px);
    --spacing-xl: clamp(32px, 8vw, 60px);
    
    --font-size-base: clamp(14px, 3.5vw, 16px);
    --font-size-sm: clamp(12px, 3vw, 14px);
    --font-size-lg: clamp(16px, 4vw, 18px);
    --font-size-xl: clamp(18px, 4.5vw, 24px);
    --font-size-2xl: clamp(20px, 5vw, 28px);
    --font-size-3xl: clamp(24px, 6vw, 36px);
    
    --line-height-base: 1.6;
    --line-height-tight: 1.4;
    --line-height-loose: 1.8;
    
    --touch-target: 44px;
    --touch-target-lg: 56px;
}

/* Typography - Mobile First */
body {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

h1 {
    font-size: var(--font-size-3xl);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-md);
}

h2 {
    font-size: var(--font-size-2xl);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: var(--font-size-xl);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-sm);
}

h4 {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-sm);
}

p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   SM: Large Phones (480px - 767px)
   ============================================ */
@media (min-width: 480px) {
    .container {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ============================================
   MD: Tablets (768px - 1023px)
   ============================================ */
@media (min-width: 768px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    h1 {
        font-size: clamp(28px, 4vw, 36px);
    }
    
    h2 {
        font-size: clamp(24px, 3.5vw, 32px);
    }
}

/* ============================================
   LG: Desktop (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .container {
        max-width: 1500px;
        padding-left: 1.875rem;
        padding-right: 1.875rem;
    }
}

/* ============================================
   STEP 3: HEADER + MENU (Mobile-First)
   ============================================ */

/* Mobile Header - Base */
.main-header {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.header-flex {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.logo-img {
    max-width: 100%;
    flex-shrink: 0;
}

.logo-img img {
    max-width: 100%;
    height: auto;
}

/* Mobile + tablet navigation — drawer closed by default (desktop from 1024px) */
@media (max-width: 1023px) {
    .navbar {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .navbar .container {
        position: relative;
        padding: var(--spacing-sm) 15px;
        min-height: var(--touch-target);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: var(--touch-target);
        min-height: var(--touch-target);
        background: var(--primary-red);
        color: white;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        z-index: 1001;
        font-size: 20px;
        transition: all 0.3s ease;
    }
    
    .nav-menu {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 320px;
        height: 100vh;
        background: linear-gradient(180deg, var(--primary-red) 0%, var(--accent-red) 100%);
        flex-direction: column;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        z-index: 9999;
        overflow-y: auto;
        overflow-x: hidden;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        padding: 80px 0 var(--spacing-lg) 0;
        visibility: hidden;
        opacity: 0;
    }
    
    .nav-menu.active {
        display: flex !important;
        transform: translateX(0);
        visibility: visible;
        opacity: 1;
    }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid rgba(255,255,255,0.15);
    }
    
    .nav-menu li a {
        padding: var(--spacing-md) var(--spacing-lg);
        min-height: var(--touch-target-lg);
        display: flex;
        align-items: center;
        font-size: var(--font-size-base);
        font-weight: 600;
        color: white;
        text-decoration: none;
        transition: all 0.3s ease;
    }
    
    .nav-menu li a:hover,
    .nav-menu li a.active {
        background: rgba(255,255,255,0.15);
        padding-left: calc(var(--spacing-lg) + 10px);
    }
}

/* Desktop Navigation (1024px+) — horizontal bar */
@media (min-width: 1024px) {
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex !important;
        position: static;
        transform: none;
        visibility: visible;
        opacity: 1;
    }
}

/* ============================================
   STEP 4: HERO SECTION
   ============================================ */

.hero-slider {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hero-slider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.6));
    z-index: 1;
}

.hero-text {
    position: relative;
    z-index: 2;
}

@media (max-width: 767px) {
    /* Home hero: same full-bleed image as desktop — sizing from index / layout overrides */
    .hero-slider:not(.home-hero-below-notification) {
        height: clamp(250px, 50vh, 400px);
        background-attachment: scroll;
    }
    
    .hero-text h2 {
        font-size: var(--font-size-2xl);
    }
    
    .hero-text p {
        font-size: var(--font-size-base);
    }
}

/* ============================================
   STEP 5: LAYOUT (Sections, Grids, Cards)
   ============================================ */

/* Remove fixed widths */
[style*="width:"] {
    max-width: 100% !important;
}

/* Responsive Grids - Mobile First (Single Column) */
.course-grid,
[style*="grid-template-columns"] {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 100%;
}

/* Tablet - 2 columns */
@media (min-width: 768px) {
    .course-grid,
    [style*="grid-template-columns: repeat(2"] {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop - 3-4 columns */
@media (min-width: 1024px) {
    .course-grid,
    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: repeat(3, 1fr);
    }
    
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Cards */
.course-card,
.card {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Sections */
section {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: var(--spacing-lg) var(--spacing-sm);
}

@media (min-width: 768px) {
    section {
        padding: var(--spacing-xl) var(--spacing-md);
    }
}

/* Main Wrapper - Mobile First */
.main-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-sm);
}

@media (min-width: 768px) {
    .main-wrapper {
        flex-direction: row;
        padding: var(--spacing-lg) var(--spacing-md);
    }
}

.sidebar {
    width: 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .sidebar {
        width: 25%;
        max-width: 300px;
    }
}

.content-area {
    width: 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .content-area {
        width: 75%;
        flex: 1;
    }
}

/* Tables - Responsive */
@media (max-width: 767px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
    }
    
    table {
        min-width: 600px;
        width: 100%;
    }
    
    /* Alternative: Stacked table rows */
    .table-stacked {
        display: block;
    }
    
    .table-stacked thead {
        display: none;
    }
    
    .table-stacked tr {
        display: block;
        margin-bottom: var(--spacing-md);
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    
    .table-stacked td {
        display: block;
        text-align: right;
        padding: var(--spacing-sm);
        border-bottom: 1px solid #eee;
    }
    
    .table-stacked td::before {
        content: attr(data-label) ": ";
        font-weight: bold;
        float: left;
    }
}

/* ============================================
   STEP 6: FOOTER (Mobile-Centered)
   ============================================ */

footer {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.footer-grid {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-sm);
}

.footer-col {
    width: 100%;
    max-width: 100%;
    text-align: center;
}

.footer-col h3 {
    text-align: center;
    margin: 0 auto var(--spacing-md);
    display: inline-block;
}

.footer-links {
    text-align: center;
    list-style: none;
    padding: 0;
}

.footer-links li {
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.footer-links li a {
    display: inline-block;
    min-height: var(--touch-target);
    padding: var(--spacing-xs) 0;
    text-align: center;
}

.contact-list {
    text-align: center;
    list-style: none;
    padding: 0;
}

.contact-list li {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-xs);
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.social-icons a {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.copyright {
    text-align: center;
    padding: var(--spacing-md) var(--spacing-sm);
}

/* Desktop Footer */
@media (min-width: 768px) {
    .footer-grid {
        flex-direction: row;
        flex-wrap: wrap;
        text-align: left;
    }
    
    .footer-col {
        flex: 1;
        min-width: 200px;
        text-align: left;
    }
    
    .footer-col h3 {
        text-align: left;
    }
    
    .footer-links {
        text-align: left;
    }
    
    .footer-links li {
        text-align: left;
    }
    
    .contact-list li {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
    }
}

/* ============================================
   STEP 7: FORMS + BUTTONS (Touch-Friendly)
   ============================================ */

/* Buttons - Touch Targets */
.btn,
button,
input[type="submit"],
input[type="button"],
a.btn {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Forms - Mobile First */
form {
    width: 100%;
    max-width: 100%;
}

.form-group {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--spacing-md);
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-height: var(--touch-target);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 16px; /* Prevents iOS zoom */
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-base);
    font-weight: 500;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Prevent overflow */
.no-overflow {
    overflow: hidden;
    max-width: 100%;
}

/* Full width on mobile */
.mobile-full {
    width: 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .mobile-full {
        width: auto;
        max-width: none;
    }
}

/* Hide on mobile */
.mobile-hide {
    display: none;
}

@media (min-width: 768px) {
    .mobile-hide {
        display: block;
    }
}

/* Show only on mobile */
.mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
}

/* ============================================
   FIX COMMON OVERFLOW ISSUES
   ============================================ */

/* 100vw can cause horizontal scroll; prefer 100% */
[style*="100vw"] {
    width: 100%;
    max-width: 100%;
}

/* Fix absolute positioned elements */
[style*="position: absolute"] {
    max-width: 100%;
}

/* Fix long words — no hyphens:auto (breaks Devanagari e.g. चिकित्सा as चिकि-सा) */
p, li, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Hindi / Devanagari: wrap at word boundaries, never soft-hyphen mid-cluster */
[lang="hi"],
[lang="hi"] p,
[lang="hi"] li,
[lang="hi"] span,
[lang="hi"] div {
    hyphens: none;
    word-break: normal;
    overflow-wrap: break-word;
}

/* Fix pre/code blocks */
pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
}

/* Fix iframes */
iframe {
    max-width: 100%;
    width: 100%;
}

/* Avoid blanket width override; layout-system handles containers */

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Reduce animations on mobile */
@media (max-width: 767px) {
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
    .marquee-scroll { animation-duration: 20s !important; }
    
    /* Disable parallax on mobile */
    [style*="background-attachment: fixed"] {
        background-attachment: scroll !important;
    }
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--primary-red);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-red);
    color: white;
    padding: var(--spacing-sm);
    text-decoration: none;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

