/* Custom section spacing reduction for main sections */
#work-related,
#features,
#subjects {
    padding-top: calc(var(--spacing-xl) / 2);
    padding-bottom: calc(var(--spacing-xl) / 2);
}

/* Responsive Breakpoints */
/* 
  - xs: 0 - 575px (phones)
  - sm: 576px - 767px (landscape phones, small tablets)
  - md: 768px - 991px (tablets)
  - lg: 992px - 1199px (desktops)
  - xl: 1200px - 1399px (large desktops)
  - xxl: 1400px and up (extra large desktops)
*/

/* Extra Small Devices (phones) */
@media (max-width: 575px) {
    /* Typography Adjustments */
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }

    /* Header & Navigation */
    .main-header {
        padding: var(--spacing-sm) 0;
    }
    
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .auth-buttons {
        display: none;
    }
    
    /* Mobile Menu (when active) */
    .mobile-menu-open .main-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--bg-color);
        padding: var(--spacing-md);
        box-shadow: var(--shadow-md);
        z-index: 1000;
    }
    
    .mobile-menu-open .main-nav ul {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li {
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li a {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        width: 100%;
    }
    
    /* Mobile dropdown toggle positioning - keep arrow to the right */
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        padding: 0.5rem 0 !important;
        width: 100% !important;
    }
    
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle i {
        margin-left: auto !important;
        flex-shrink: 0 !important;
        font-size: 0.8rem !important;
        transition: transform 0.3s ease !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    
    /* Override any potential conflicting styles */
    @media (max-width: 575px) {
        .dropdown-toggle {
            flex-direction: row !important;
            white-space: nowrap !important;
        }
        
        .dropdown-toggle i {
            margin-left: auto !important;
            display: inline-block !important;
        }
    }
    
    /* Override inline styles with even more specific selectors */
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        padding: 0.5rem 0 !important;
        width: 100% !important;
        line-height: 1 !important;
    }
    
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle i {
        margin-left: auto !important;
        flex-shrink: 0 !important;
        font-size: 0.8rem !important;
        transition: transform 0.3s ease !important;
        display: inline-flex !important;
        align-items: center !important;
        line-height: 1 !important;
        color: rgba(255, 255, 255, 0.8) !important;
        min-width: 16px !important;
        justify-content: center !important;
    }
    
    /* Debug styles to help identify the issue */
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle {
        background-color: rgba(255, 0, 0, 0.1) !important;
        border: 1px solid red !important;
    }
    
    body.mobile-menu-open .nav-links .dropdown .dropdown-toggle i {
        background-color: rgba(0, 255, 0, 0.2) !important;
        border: 1px solid green !important;
    }
    
    body.mobile-menu-open .nav-links li {
        background-color: rgba(0, 0, 255, 0.1) !important;
        border: 1px solid blue !important;
    }
    
    .mobile-menu-open .auth-buttons {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
        margin-top: var(--spacing-md);
        align-items: flex-start;
        width: 100%;
    }
    

    
    /* Features & Subjects */
    .features-grid, .subjects-grid {
        grid-template-columns: 1fr;
    }
    
    /* Testimonials */
    .testimonials-slider {
        flex-direction: column;
    }
    
    .testimonial-card {
        min-width: auto;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }
    
    .footer-links {
        grid-template-columns: 1fr;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
    
    /* Showcase Container Mobile Optimizations */
    .showcase-container {
        padding: 0 1rem;
        gap: 1rem;
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
    }
    
    .showcase-left {
        width: 100%;
        overflow: hidden;
    }
    
    .showcase-right {
        width: 100%;
        padding: 0;
    }
    .photo-carousel {
        aspect-ratio: 4/5;
        min-height: 350px;
        max-height: 400px;
        width: 100%;
        margin: 0 auto;
    }
    
    .carousel-slide .carousel-image {
        width: 95%;
        height: 75%;
        border-radius: 10px;
        background-size: contain !important;
        background-position: center top;
        background-repeat: no-repeat;
        object-fit: contain;
        top: 5%;
        transform: translateX(-50%);
    }
    
    .carousel-overlay {
        padding: 1rem 0.75rem 0.75rem;
        position: absolute;
        bottom: 8%;
        left: 2.5%;
        right: 2.5%;
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
        color: white;
        transform: translateY(0);
        transition: transform 0.4s ease-in-out;
        border-radius: 8px;
        backdrop-filter: blur(10px);
        width: 95%;
        box-sizing: border-box;
    }
    
    /* Ensure carousel overlay is always visible on mobile */
    .carousel-slide .carousel-overlay,
    .carousel-slide.active .carousel-overlay {
        transform: translateY(0);
        opacity: 1;
    }
    
    .carousel-overlay h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }
    
    .carousel-overlay p {
        font-size: 0.9rem;
        opacity: 0.95;
        margin: 0;
        line-height: 1.4;
    }
    
    .carousel-indicators {
        bottom: 1.5rem;
        gap: 0.5rem;
        width: 90%;
        max-width: 250px;
    }
    
    .indicator {
        height: 3px;
        min-width: 20px;
    }
    
    /* Timeline */
    .timeline::before {
        left: 30px;
    }
    
    .timeline-item {
        width: 100%;
        padding-left: 70px;
    }
    
    .timeline-item:nth-child(even) {
        left: 0;
    }
    
    .timeline-item:nth-child(odd) .timeline-content::after,
    .timeline-item:nth-child(even) .timeline-content::after {
        display: none;
    }
    
    .timeline-item:nth-child(odd) .timeline-date,
    .timeline-item:nth-child(even) .timeline-date {
        left: -60px;
        width: 80px;
        font-size: 0.75rem;
    }
    
    .timeline-item:nth-child(odd) .timeline-dot,
    .timeline-item:nth-child(even) .timeline-dot {
        left: 22px;
    }
    
    .profile-section {
        display: none;
    }
    
    .mobile-menu-open .profile-section {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        margin: 1rem 0;
        order: 3;
    }
    
    .mobile-menu-open .profile-button {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .mobile-menu-open .profile-display {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
    
    /* Fault Statistics Page Mobile Optimizations */
    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
        min-height: auto;
    }
    
    .stat-icon {
        font-size: 2.5rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .chart-container {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .chart-filter {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .filter-select {
        min-width: 100px;
        font-size: 0.85rem;
    }
    
    #faultTypeChart, #trendChart {
        height: 300px !important;
        width: 100% !important;
    }
    
    main {
        padding: 1rem;
        margin-top: 0; /* Header is no longer fixed */
    }
    
    .content-title {
        font-size: 1.5rem;
        text-align: center;
    }
    
    /* Mobile: Make quote-box and ai-exploration-box same height as photo-carousel */
    .quote-box,
    .ai-exploration-box {
        min-height: 350px;
        max-height: 400px;
        height: auto !important; /* Override height: 100% */
    }
    
    .keywords-box {
        min-height: 175px; /* Half height for keywords box */
        max-height: 200px;
        height: auto !important;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
}

/* Small Devices (landscape phones, small tablets) */
@media (min-width: 576px) and (max-width: 767px) {
    /* Header & Navigation */
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .auth-buttons {
        display: none;
    }
    
    /* Mobile Menu (when active) */
    .mobile-menu-open .main-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--bg-color);
        padding: var(--spacing-md);
        box-shadow: var(--shadow-md);
        z-index: 1000;
    }
    
    .mobile-menu-open .main-nav ul {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li {
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li a {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        width: 100%;
    }
    
    .mobile-menu-open .auth-buttons {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
        margin-top: var(--spacing-md);
        align-items: flex-start;
        width: 100%;
    }
    
    /* Hero Section */
    .hero-section .container {
        flex-direction: column;
    }
    
    .hero-content {
        text-align: center;
        margin-bottom: var(--spacing-xl);
    }
    
    .hero-buttons {
        justify-content: center;
    }
    
    /* Features & Subjects */
    .features-grid, .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }
    
    .footer-links {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Timeline */
    .timeline::before {
        left: 40px;
    }
    
    .timeline-item {
        width: 100%;
        padding-left: 80px;
    }
    
    .timeline-item:nth-child(even) {
        left: 0;
    }
    
    .timeline-item:nth-child(odd) .timeline-content::after,
    .timeline-item:nth-child(even) .timeline-content::after {
        display: none;
    }
    
    .timeline-item:nth-child(odd) .timeline-date,
    .timeline-item:nth-child(even) .timeline-date {
        left: -50px;
        width: 80px;
    }
    
    .timeline-item:nth-child(odd) .timeline-dot,
    .timeline-item:nth-child(even) .timeline-dot {
        left: 31px;
    }
    
    .profile-section {
        flex-direction: column;
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .profile-display {
        margin-left: 0;
        margin-top: 0.5rem;
        text-align: center;
    }
    
    /* Fault Statistics Page Tablet Optimizations */
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .stat-card {
        padding: 1.75rem;
    }
    
    .chart-container {
        padding: 1.25rem;
    }
    
    .chart-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    #faultTypeChart, #trendChart {
        height: 350px !important;
    }
    
    main {
        padding: 1.5rem;
    }
    
    .content-title {
        font-size: 1.6rem;
    }
    
    /* Photo Carousel Tablet Optimizations */
    .photo-carousel {
        aspect-ratio: 16/10;
        max-height: 400px;
    }
    
    .carousel-slide .carousel-image {
        width: 88%;
        height: 88%;
        border-radius: 12px;
        background-size: contain !important;
        background-position: center;
        background-repeat: no-repeat;
    }
}

/* Medium Devices (tablets) */
@media (min-width: 768px) and (max-width: 991px) {
    /* Header & Navigation */
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Mobile Menu (when active) */
    .mobile-menu-open .main-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--bg-color);
        padding: var(--spacing-md);
        box-shadow: var(--shadow-md);
        z-index: 1000;
    }
    
    .mobile-menu-open .main-nav ul {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li {
        width: 100%;
    }
    
    .mobile-menu-open .main-nav ul li a {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        width: 100%;
    }
    

    
    /* Features & Subjects */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .footer-logo {
        grid-column: 1 / -1;
        margin-bottom: var(--spacing-lg);
    }
    
    .footer-links {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Devices (desktops) */
@media (min-width: 992px) and (max-width: 1199px) {

    /* Box Height Optimization - Equal height for quote and AI exploration boxes */
    .quote-box {
        min-height: 280px; /* Set consistent height for desktop screens */
        max-height: 350px; /* Allow for content expansion */
        padding: 1.75rem;
        height: 100%; /* Match parent container height */
    }
    
    .ai-exploration-box {
        min-height: 280px !important; /* Set same height as quote box - use important to override keywords-box */
        max-height: 380px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important; /* Match parent container height - use important to override keywords-box */
    }
    
    /* More specific selector for AI exploration box to override keywords-box */
    .keywords-box.ai-exploration-box {
        min-height: 280px !important;
        max-height: 380px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important;
    }
    
    .keywords-box {
        min-height: 140px; /* Reduced from 280px to 140px (half) */
        max-height: 175px; /* Reduced from 350px to 175px (half) */
        padding: 1.75rem;
    }
    
    .ai-exploration-content {
        padding: 1.5rem; /* Slightly reduced padding for smaller boxes */
        padding-bottom: 1.25rem; /* Slightly reduce bottom padding to accommodate button */
    }
    
    .ai-exploration-footer {
        margin-top: 0.5rem; /* Add small margin to ensure button clearance */
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr 2fr 1fr;
    }
    
    /* Photo Carousel Desktop Optimizations */
    .photo-carousel {
        aspect-ratio: 4/3;
        min-height: 300px;
        max-height: 350px;
    }
    
    .carousel-slide .carousel-image {
        width: 90%;
        height: 70%;
        border-radius: 12px;
        background-size: contain !important;
        background-position: center top;
        background-repeat: no-repeat;
        top: 5%;
        transform: translateX(-50%);
    }
    
    .carousel-overlay {
        bottom: 8%;
        left: 5%;
        right: 5%;
        width: 90%;
        padding: 1rem;
    }
    
    /* Box Height Reduction for Desktop - 20% reduction */
    .quote-box {
        min-height: 200px; /* Reduced from 250px */
        padding: 1.5rem; /* Reduced padding */
    }
    
    .ai-exploration-box {
        min-height: 200px; /* Reduced from default */
    }
    
    .ai-exploration-content {
        padding: 1.5rem; /* Reduced padding */
    }
    
    .keywords-box {
        min-height: 200px; /* Reduced from default */
        padding: 1.5rem; /* Reduced padding */
    }
}

/* Extra Large Devices (large desktops) */
@media (min-width: 1200px) and (max-width: 1399px) {
    /* Container */
    .container {
        max-width: 1140px;
    }
    
    /* Box Height Optimization - Equal height for quote and AI exploration boxes */
    .quote-box {
        min-height: 300px; /* Set consistent height for large desktop screens */
        max-height: 380px; /* Allow for content expansion */
        padding: 2rem;
        height: 100%; /* Match parent container height */
    }
    
    .ai-exploration-box {
        min-height: 300px !important; /* Set same height as quote box - use important to override keywords-box */
        max-height: 420px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important; /* Match parent container height - use important to override keywords-box */
    }
    
    /* More specific selector for AI exploration box to override keywords-box */
    .keywords-box.ai-exploration-box {
        min-height: 300px !important;
        max-height: 420px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important;
    }
    
    .keywords-box {
        min-height: 140px; /* Reduced from 280px to 140px (half) */
        max-height: 175px; /* Reduced from 350px to 175px (half) */
        padding: 1.75rem;
    }
    
    .ai-exploration-content {
        padding: 1.5rem; /* Slightly reduced padding for smaller boxes */
        padding-bottom: 1.25rem; /* Slightly reduce bottom padding to accommodate button */
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Box Height Reduction for Large Desktop - 20% reduction */
    .quote-box {
        min-height: 200px; /* Reduced from 250px */
        padding: 1.5rem; /* Reduced padding */
    }
    
    .ai-exploration-box {
        min-height: 200px; /* Reduced from default */
    }
    
    .ai-exploration-content {
        padding: 1.5rem; /* Reduced padding */
    }
    
    .keywords-box {
        min-height: 200px; /* Reduced from default */
        padding: 1.5rem; /* Reduced padding */
    }
}

/* Extra Extra Large Devices (extra large desktops) */
@media (min-width: 1400px) {
    /* Container */
    .container {
        max-width: 1320px;
    }
    
    /* Box Height Optimization - Equal height for quote and AI exploration boxes */
    .quote-box {
        min-height: 320px; /* Set consistent height for wide screens */
        max-height: 400px; /* Allow for content expansion */
        padding: 2rem;
        height: 100%; /* Match parent container height */
    }
    
    .ai-exploration-box {
        min-height: 320px !important; /* Set same height as quote box - use important to override keywords-box */
        max-height: 440px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important; /* Match parent container height - use important to override keywords-box */
    }
    
    /* More specific selector for AI exploration box to override keywords-box */
    .keywords-box.ai-exploration-box {
        min-height: 320px !important;
        max-height: 440px !important; /* Increased max-height to prevent button cutoff */
        height: 100% !important;
    }
    
    .keywords-box {
        min-height: 160px; /* Reduced from 320px to 160px (half) */
        max-height: 200px; /* Reduced from 400px to 200px (half) */
        padding: 2rem;
    }
    
    .ai-exploration-content {
        padding: 2rem;
        padding-bottom: 1.75rem; /* Slightly reduce bottom padding for button clearance */
    }
    
    .ai-exploration-footer {
        margin-top: 0.5rem; /* Add small margin to ensure button clearance */
    }
}

/* Print Styles */
@media print {
    /* Hide elements not necessary for print */
    .main-header, .main-footer, .cta-section {
        display: none !important;
    }
    
    /* Adjust typography for print */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background-color: #fff;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    p, blockquote, ul, ol, dl, table {
        page-break-inside: avoid;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    /* Ensure links show their URL in print */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 90%;
        color: #666;
    }
    
    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }
    
    /* Create sections for print */
    .section-header {
        margin-top: 1cm;
    }
}

/* About Section Responsive */
@media (max-width: 1200px) {
  .about-cards {
    gap: 20px;
  }
}

@media (max-width: 992px) {
  .about-cards {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .about-section {
    padding: 50px 0;
  }
  
  .about-cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 30px;
  }
  
  .about-card-icon {
    width: 50px;
    height: 50px;
  }
  
  .about-card-icon svg {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 576px) {
  .about-cards {
    grid-template-columns: 1fr;
  }
  
  .about-card {
    padding: 20px;
  }
  
  .about-card h3 {
    font-size: 1.2rem;
  }
  
  .about-card p,
  .about-list li {
    font-size: 0.95rem;
  }
}

/* Subject Grid Responsive */
@media (max-width: 1200px) {
    .subjects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .subjects-grid {
        grid-template-columns: 1fr;
    }
    
    .subject-icon-container {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .subject-icon {
        font-size: 1.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        margin: 0;
        line-height: 1;
    }
}

@media (max-width: 400px) {
    .subject-icon-container {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .subject-icon {
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        margin: 0;
        line-height: 1;
    }
}