/* Responsive Styles */

/* ==================== GLOBAL MOBILE OVERFLOW FIX ==================== */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Tablet */
@media (max-width: 960px) {
    .steps-row {
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }

    .steps-row::before {
        display: none;
    }

    .cta-inner {
        flex-direction: column;
        text-align: center;
    }

    .cta-btns {
        justify-content: center;
    }

    .accent-band-inner {
        flex-direction: column;
        text-align: center;
    }

    .about-grid,
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .benefits-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 800px) {
    .nav-links {
        display: none;
    }

    .nav-actions {
        display: none;
    }

    .hamburger {
        display: block;
    }

    .nav-inner {
        padding: 0 12px;
    }

    .mobile-menu {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--border);
        padding: 16px var(--spacing-xl) 20px;
        box-shadow: 0 12px 32px rgba(15, 32, 68, 0.10);
        z-index: 400;
    }

    .mobile-menu.open {
        display: block;
    }

    .mobile-menu ul {
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-bottom: 14px;
    }

    .mobile-menu ul a {
        display: block;
        padding: 10px 12px;
        font-size: 0.82rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        color: var(--muted);
        text-decoration: none;
        border-radius: var(--radius-md);
    }

    .mobile-menu ul a:hover {
        background: var(--mist);
        color: var(--navy);
    }

    .mobile-menu-btns {
        display: flex;
        gap: 10px;
    }

    .hero-stats-inner {
        flex-wrap: wrap;
        padding: 0 24px;
    }

    .hero-stat {
        min-width: 50%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .hero-stat:last-child {
        border-bottom: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    /* Admin Sidebar Collapse */
    .sidebar {
        width: 64px;
    }

    .sidebar-brand .brand-text,
    .sidebar-brand .logo-comm,
    .sidebar-nav a span:not(.nav-icon),
    .sidebar-section-label,
    .sidebar-footer a span:not(.nav-icon) {
        display: none;
    }

    .sidebar-brand {
        padding: 12px 10px;
        justify-content: center;
    }

    .sidebar-brand .logo-brgy {
        height: 36px;
    }

    .sidebar-nav a {
        justify-content: center;
        padding: 10px;
    }

    .sidebar-footer a {
        justify-content: center;
        padding: 10px;
    }

    .summary-strip {
        grid-template-columns: 1fr 1fr;
    }

    /* --- Logo images: scale down for mobile navbar --- */
    .nav-brand .logo-brgy {
        height: 34px;
    }

    .nav-brand .logo-comm {
        height: 28px;
    }

    .brand-text {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }
}

/* Small Mobile */
@media (max-width: 640px) {
    .hero-content {
        padding: 70px 24px 90px;
    }

    .auth-card {
        padding: 36px 24px;
    }

    .steps-row {
        grid-template-columns: 1fr;
    }

    .admin-content {
        padding: 16px;
    }

    .modal-grid-2,
    .modal-grid-3,
    .report-date-row {
        grid-template-columns: 1fr;
    }

    .report-options {
        grid-template-columns: 1fr;
    }

    .summary-strip {
        grid-template-columns: 1fr;
    }

    .auth-form .form-row-2 {
        grid-template-columns: 1fr;
    }
}

/* Extra Small */
@media (max-width: 480px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .topbar-inner {
        justify-content: center;
    }
}

/* ==================== MOBILE 390px OPTIMIZATIONS ==================== */

/* --- Index.php Hero: scale down for mobile --- */
@media (max-width: 768px) {
    .hero-content {
        padding: 40px 18px 32px;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-sub {
        font-size: 0.92rem;
        margin-bottom: 22px;
    }

    .hero-btns {
        flex-direction: column;
        gap: 10px;
    }

    .hero-btns .btn {
        width: 100%;
        text-align: center;
    }

    .hero-eyebrow {
        font-size: 0.65rem;
        letter-spacing: 2px;
    }

    .hero-stats-inner {
        padding: 0 16px;
        gap: 0;
    }

    .hero-stat {
        padding: 10px 0;
    }

    .hero-stat-num {
        font-size: 1.5rem;
    }

    .hero-stat-label {
        font-size: 0.6rem;
    }

    .section {
        padding: 48px 0;
    }

    .section-title {
        font-size: 1.7rem;
    }

    .section-text {
        font-size: 0.9rem;
    }

    .accent-band-text {
        font-size: 1.1rem;
    }

    .accent-band-sub {
        font-size: 0.78rem;
    }

    .accent-band-inner {
        padding: 0 18px;
    }

    .container {
        padding-left: 18px;
        padding-right: 18px;
    }

    .cta-text h2 {
        font-size: 2rem;
    }

    .contact-form {
        padding: 20px;
    }

    /* --- Index.php: scale hero background image for mobile --- */
    .hero {
        background-size: cover;
        background-position: center center;
    }

    .hero::before {
        width: 100%;
        clip-path: none;
        background: rgba(217, 43, 43, 0.04);
    }
}

/* --- Logged-in pages: show Logout button + hamburger on mobile --- */
@media (max-width: 800px) {
    .history-page .nav-actions,
    .profile-page .nav-actions,
    .complaint-page .nav-actions {
        display: flex !important;
        gap: 6px;
    }
    .history-page .nav-actions .btn,
    .profile-page .nav-actions .btn,
    .complaint-page .nav-actions .btn {
        padding: 5px 10px;
        font-size: 0.62rem;
        letter-spacing: 0.4px;
        white-space: nowrap;
    }
}

/* --- OTP Input: fix number cutoff on ALL mobile sizes --- */
@media (max-width: 768px) {
    .otp-inputs {
        gap: 6px;
        justify-content: center;
        flex-wrap: nowrap;
    }

    .otp-input {
        width: 44px;
        height: 54px;
        font-size: 22px;
        padding: 0 !important;
        line-height: 54px;
        text-align: center;
        border-radius: 10px;
        -webkit-text-fill-color: var(--navy, #0f2044);
    }
}

@media (max-width: 480px) {
    .otp-inputs {
        gap: 5px;
    }

    .otp-input {
        width: 40px;
        height: 50px;
        font-size: 20px;
        line-height: 50px;
        padding: 0 !important;
        border-radius: 8px;
    }

    .auth-card {
        padding: 28px 16px;
    }

    .auth-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 380px) {
    .otp-inputs {
        gap: 4px;
    }

    .otp-input {
        width: 36px;
        height: 46px;
        font-size: 18px;
        line-height: 46px;
    }
}

/* --- Submit Complaint: fit form on mobile without horizontal scroll --- */
@media (max-width: 768px) {
    .complaint-page {
        overflow-x: hidden;
    }

    .complaint-wrap {
        padding: 20px 8px 40px;
        overflow-x: hidden;
    }

    .complaint-wrap::before {
        display: none;
    }

    .complaint-card {
        max-width: 100%;
        border-radius: 16px;
        overflow: hidden;
    }

    .complaint-header {
        padding: 18px 14px;
        gap: 10px;
    }

    .complaint-header::after {
        display: none;
    }

    .complaint-header-text h1 {
        font-size: 1.05rem;
    }

    .complaint-header-text p {
        font-size: 0.68rem;
    }

    .complaint-header-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .complaint-body {
        padding: 16px 12px;
        gap: 18px;
    }

    .track-selector {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .track-card {
        padding: 14px 14px 14px 44px;
    }

    .track-card input[type="radio"] {
        left: 14px;
    }

    .track-card h3 {
        font-size: 0.86rem;
    }

    .track-card p {
        font-size: 0.72rem;
    }

    .track-examples {
        margin-top: 6px;
    }

    .track-tag {
        font-size: 0.64rem;
    }

    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .form-grid-2-1 {
        grid-template-columns: 1fr;
    }

    .form-section {
        padding: 12px;
        border-width: 1.5px;
    }

    .form-section-label {
        font-size: 0.85rem;
        letter-spacing: 1px;
    }

    .field label {
        font-size: 0.7rem;
    }

    .field input,
    .field select,
    .field textarea {
        font-size: 0.85rem;
        padding: 10px 12px;
        max-width: 100%;
    }

    .submit-row {
        flex-direction: column;
        gap: 14px;
        text-align: center;
    }

    .submit-row .btn {
        width: 100%;
    }

    .submit-note {
        font-size: 0.72rem;
    }

    .submit-note br {
        display: none;
    }

    .upload-area {
        padding: 16px 12px;
    }

    .upload-inner {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .upload-area-text strong {
        font-size: 0.74rem;
    }

    .upload-area-text span {
        font-size: 0.7rem;
    }

    .file-pill {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

    .upload-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .success-card {
        padding: 36px 16px;
    }

    .ref-badge {
        font-size: 1rem;
        padding: 6px 14px;
    }

    .consent-box {
        padding: 12px 10px;
    }

    .consent-label {
        font-size: 0.76rem;
        gap: 8px;
    }

    .kp-section-note {
        font-size: 0.70rem !important;
        padding: 8px 10px !important;
    }

    .section-divider {
        margin: 6px 0 8px;
    }

    /* Footer on complaint page */
    .complaint-page .footer-inner {
        padding: 0 16px;
        font-size: 0.75rem;
    }

    /* --- My Complaints table: fit on mobile --- */
    .history-page {
        overflow-x: hidden;
    }
    .history-wrap {
        padding: 20px 8px 40px;
        overflow-x: hidden;
    }
    .history-wrap::before {
        display: none;
    }
    .history-card {
        max-width: 100%;
        border-radius: 16px;
        overflow: hidden;
    }
    .history-header {
        padding: 16px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .history-header::after {
        display: none;
    }
    .history-header-left h1 {
        font-size: 1rem;
    }
    .history-header-left p {
        font-size: 0.65rem;
    }
    .filters-row {
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
    }
    .filter-select-wrap {
        min-width: unset;
        width: 100%;
    }
    .search-wrap {
        min-width: unset;
        width: 100%;
    }
    .btn-refresh {
        padding: 8px 14px;
        font-size: 0.65rem;
    }
    .live-indicator {
        font-size: 0.6rem;
        padding: 4px 8px;
    }
    /* Hide Location column on mobile to save space */
    .history-page table th:nth-child(4),
    .history-page table td:nth-child(4) {
        display: none;
    }
    .history-page thead th {
        padding: 10px 6px;
        font-size: 0.55rem;
        letter-spacing: 0.6px;
    }
    .history-page tbody td {
        padding: 10px 6px;
        font-size: 0.72rem;
    }
    .history-page .td-id {
        font-size: 0.65rem;
        word-break: break-all;
    }
    .history-page .td-date {
        font-size: 0.68rem;
    }
    .history-page .btn-view {
        padding: 5px 8px;
        font-size: 0.58rem;
    }
    .history-page .status-badge {
        font-size: 0.58rem;
        padding: 3px 7px;
    }
    .history-footer {
        padding: 14px 12px;
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 10px;
    }
    .btn-new-request {
        justify-content: center;
        font-size: 0.7rem;
        padding: 10px 16px;
    }
    /* Modal on mobile */
    .modal-box {
        max-width: 100%;
        border-radius: 14px;
    }
    .modal-grid-2, .modal-grid-3 {
        grid-template-columns: 1fr;
    }

    /* --- Profile page: fit on mobile --- */
    .profile-page {
        overflow-x: hidden;
    }
    .profile-wrap {
        padding: 20px 8px 40px;
    }
    .profile-wrap::before {
        display: none;
    }
    .profile-card {
        max-width: 100%;
    }
    .profile-head {
        padding: 18px 14px;
    }
    .profile-body {
        padding: 20px 14px;
    }
    .profile-body .field input {
        font-size: 0.85rem;
    }
}