/* Global responsive helpers */

img,
video,
iframe,
svg {
    max-width: 100%;
    height: auto;
}

table {
    width: 100%;
}

@media (max-width: 992px) {
    .top-bar-content {
        justify-content: center;
        gap: 0.75rem;
    }

    .top-bar-item {
        font-size: 0.7rem;
    }

    .main-nav {
        padding: 0.5rem 4%;
    }

    .logo-img {
        max-height: 48px;
    }
}

@media (max-width: 768px) {
    /* Hero sizing and text (non-home pages) */
    .hero-section {
        padding: 70px 5% 45px !important;
        margin-top: 0 !important;
        display: flex;
        align-items: center;
    }

    .hero-section > div:last-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .hero-section > div:last-child > div {
        margin-bottom: 0 !important;
    }

    .hero-section .hero-title,
    .hero-section .hero-desc {
        margin: 0 !important;
    }

    .hero-section .hero-title {
        font-size: 1.9rem;
        line-height: 0.9;
        margin: 0 !important;
    }

    .hero-section .hero-desc {
        font-size: 0.92rem;
        line-height: 1.15;
        max-width: 90%;
        margin: 0 !important;
        margin-top: -1.05rem !important;
    }

    .hero-section [style*="margin-bottom: 1.5rem"] {
        margin-bottom: 0 !important;
    }

    .hero-section [style*="padding: 0.5rem 1.25rem"] {
        padding: 0.4rem 1rem !important;
        font-size: 0.8rem !important;
    }

    .top-bar {
        display: none;
    }

    .desktop-search-toggle {
        display: none;
    }

    .nav-links .dropdown {
        position: static;
        box-shadow: none;
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .footer-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.5rem 6%;
    }

    .footer-section {
        width: 100%;
    }

    /* Tracer Dashboard */
    .chart-container {
        height: 250px;
    }

    .status-table {
        font-size: 0.9rem;
    }

    .status-table th,
    .status-table td {
        padding: 0.75rem !important;
        font-size: 0.85rem;
    }

    /* Modal Responsive */
    .modal-dialog {
        margin: 1rem !important;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-header h5 {
        font-size: 1.25rem;
    }

    /* Admin Dashboard Cards */
    [class*="col-md-"]:not([class*="col-sm-"]):not([class*="col-xs-"]) {
        min-width: 100%;
    }

    /* Button Group Responsive */
    .btn-group,
    [class*="filter-"] {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    /* Hero sizing and text (non-home pages) */
    .hero-section {
        padding: 55px 4% 38px !important;
        margin-top: 0 !important;
    }

    .hero-section > div:last-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .hero-section > div:last-child > div {
        margin-bottom: 0 !important;
    }

    .hero-section .hero-title,
    .hero-section .hero-desc {
        margin: 0 !important;
    }

    .hero-section .hero-title {
        font-size: 1.65rem;
        line-height: 0.9;
        margin: 0 !important;
    }

    .hero-section .hero-desc {
        font-size: 0.88rem;
        line-height: 1.1;
        max-width: 92%;
        margin: 0 !important;
        margin-top: -1.1rem !important;
    }

    .hero-section [style*="margin-bottom: 1.5rem"],
    .hero-section [style*="margin-bottom: 1rem"] {
        margin-bottom: 0 !important;
    }

    .hero-section [style*="padding: 0.5rem 1.25rem"] {
        padding: 0.35rem 0.9rem !important;
        font-size: 0.75rem !important;
    }

    .footer-content {
        padding: 1.5rem 4%;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h3 {
        font-size: 1rem;
    }

    .footer-logo-section {
        text-align: center;
    }

    /* Tracer Dashboard Mobile */
    [style*="padding: 3rem"] {
        padding: 1.5rem 5% !important;
    }

    [style*="max-width: 1200px"] {
        padding: 1rem 5%;
    }

    .status-table {
        font-size: 0.8rem;
    }

    .status-table th,
    .status-table td {
        padding: 0.5rem !important;
    }

    .status-table th:first-child,
    .status-table td:first-child {
        width: 30px;
    }

    /* Modal Responsive */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        border-radius: 12px;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
    }

    /* Full width inputs on mobile */
    .form-control,
    .form-select,
    .btn {
        font-size: 16px;
    }

    /* Stack form buttons */
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .modal-footer .btn:last-child {
        margin-bottom: 0;
    }

    /* Cards */
    [class*="card"] {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    /* Filter Buttons */
    .filter-btn {
        flex: 1 1 calc(50% - 0.25rem);
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Hero Section Mobile */
    [class*="hero"] {
        padding: 60px 4% 40px !important;
    }

    [class*="hero"] h1,
    [style*="font-size: 3.5rem"] {
        font-size: 1.8rem;
    }

    [class*="hero"] p,
    [style*="font-size: 1.2rem"] {
        font-size: 0.95rem;
    }
}

@media (min-width: 1920px) {
    body {
        font-size: clamp(16px, 0.8vw, 18px);
    }

    .main-nav,
    .content,
    .section,
    .page-section,
    .footer-content,
    .quick-links {
        max-width: min(92vw, 2000px);
        margin-left: auto;
        margin-right: auto;
    }

    .section-header h2 {
        font-size: clamp(2rem, 1.8vw, 2.5rem);
    }

    .section-header p {
        font-size: clamp(0.95rem, 0.9vw, 1.1rem);
    }

    .quick-links {
        padding: clamp(60px, 3vw, 80px) clamp(24px, 1.5vw, 40px);
    }

    .quick-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
        gap: clamp(24px, 1.5vw, 32px) !important;
        max-width: min(90vw, 1800px);
        margin: 0 auto;
    }

    .quick-card {
        padding: clamp(24px, 1.5vw, 32px);
    }

    .quick-card i {
        font-size: clamp(2.5rem, 2vw, 3.2rem) !important;
    }

    .quick-card h3 {
        font-size: clamp(1rem, 0.95vw, 1.2rem);
    }

    .quick-subtitle {
        font-size: clamp(0.85rem, 0.8vw, 1rem);
    }

    .btn-primary,
    .btn-secondary {
        padding: clamp(12px, 0.7vw, 16px) clamp(32px, 1.8vw, 44px);
        font-size: clamp(0.95rem, 0.85vw, 1.05rem);
    }

    /* Hero Slider */
    .hero-slider {
        height: clamp(600px, 35vw, 800px) !important;
    }

    .slider-content h2 {
        font-size: clamp(2.8rem, 2.5vw, 3.8rem) !important;
    }

    .slider-content p {
        font-size: clamp(1.1rem, 1vw, 1.4rem) !important;
    }

    /* Berita Section */
    .berita-section,
    .prestasi-section {
        padding: clamp(80px, 4.5vw, 100px) 0;
    }

    .berita-section .container,
    .prestasi-section .container {
        max-width: min(90vw, 1800px) !important;
        padding: 0 clamp(24px, 1.5vw, 40px) !important;
    }

    .berita-grid {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)) !important;
        gap: clamp(24px, 1.5vw, 32px) !important;
        margin-top: clamp(40px, 2.5vw, 50px) !important;
    }

    .berita-card img,
    .berita-card > div {
        height: clamp(200px, 11vw, 240px) !important;
    }

    .berita-card-body {
        padding: clamp(24px, 1.5vw, 28px) !important;
    }

    .berita-card h3 {
        font-size: clamp(1.1rem, 1vw, 1.3rem) !important;
    }

    .berita-card p {
        font-size: clamp(0.9rem, 0.85vw, 1rem) !important;
    }

    /* Prestasi Section */
    .prestasi-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
        gap: clamp(24px, 1.5vw, 32px) !important;
        margin-top: clamp(40px, 2.5vw, 50px) !important;
    }

    .prestasi-card img,
    .prestasi-card > div {
        height: clamp(280px, 15vw, 330px) !important;
    }

    .prestasi-card-body {
        padding: clamp(24px, 1.5vw, 28px) clamp(20px, 1.2vw, 24px) !important;
    }

    .prestasi-card h3 {
        font-size: clamp(1.05rem, 0.95vw, 1.25rem) !important;
    }

    .prestasi-detail {
        font-size: clamp(0.9rem, 0.85vw, 1rem) !important;
    }

    /* News cards in main section */
    .news-card {
        padding: clamp(20px, 1.2vw, 28px) !important;
    }

    .news-card h3 {
        font-size: clamp(1.1rem, 1vw, 1.3rem) !important;
    }

    .news-card p {
        font-size: clamp(0.9rem, 0.85vw, 1rem) !important;
    }

    /* Sidebar */
    .sidebar-widget {
        padding: clamp(20px, 1.3vw, 28px) !important;
    }

    .sidebar-widget h3 {
        font-size: clamp(1rem, 0.95vw, 1.2rem) !important;
    }

    .sidebar-widget li a {
        font-size: clamp(0.9rem, 0.85vw, 1rem) !important;
    }
}
