/* =============================================================
   QPTEO Portal — Dedicated Mobile Stylesheet
   Path: assets/mobile/mobile.css
   Isolates all mobile-specific layout behaviors and enhancements
   without cluttering or modifying the desktop/web layout.
   ============================================================= */

/* ---------- Mobile Responsive Scope (< 768px) ---------- */
@media (max-width: 768px) {

    /* --- 1. Header (Navbar) Mobile Refinements --- */
    .qpteo-navbar {
        border-bottom-width: 3px;
    }

    .qpteo-navbar-container {
        padding: 0.35rem 0.65rem;
        gap: 0.45rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .qpteo-brand {
        flex-shrink: 0;
        margin-right: 0.25rem;
    }

    .qpteo-navbar-logo {
        height: 48px;
        max-width: 150px;
        object-fit: contain;
    }

    .qpteo-mobile-toggle {
        display: flex;
        padding: 0.3rem 0.45rem;
        border-radius: 6px;
        border-width: 1.5px;
        flex-shrink: 0;
    }

    .qpteo-mobile-toggle svg {
        width: 20px;
        height: 20px;
    }

    /* Shrink search bar height so it doesn't eat vertical screen */
    .qpteo-search-box {
        margin: 0;
        flex: 1;
        min-width: 0;
        max-width: none;
    }

    .qpteo-search-form {
        width: 100%;
    }

    .qpteo-search-input-wrapper {
        width: 100%;
    }

    .qpteo-search-input {
        width: 100% !important;
        height: 33px;
        font-size: 0.78rem;
        padding: 0.25rem 1.6rem 0.25rem 2rem;
        border-radius: 17px;
        border-width: 1.5px;
    }

    .qpteo-search-icon {
        left: 0.55rem;
        width: 14px;
        height: 14px;
    }

    .qpteo-search-clear {
        right: 0.55rem;
        font-size: 1rem;
    }

    /* Dropdown search results positioning */
    .qpteo-search-results-dropdown {
        left: -80px;
        right: 0;
        width: auto;
        max-width: 95vw;
    }

    /* --- 2. Hero Section Mobile Optimization --- */
    .qpteo-carousel-wrapper {
        margin: 0.65rem auto 0.25rem;
        padding: 0 0.85rem;
        width: 100%;
    }

    .qpteo-carousel-card {
        width: 100%;
        background: #ffffff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 14px rgba(4, 4, 132, 0.08);
        border: 1px solid rgba(4, 4, 132, 0.09);
    }

    .qpteo-carousel {
        border-radius: 12px 12px 0 0;
    }

    .qpteo-carousel-slide {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* Reduce image height to 200px max */
    .qpteo-carousel-slide img {
        width: 100%;
        height: 175px;
        max-height: 200px;
        object-fit: cover;
        display: block;
    }

    /* Short title & one-line caption under image inside card */
    .qpteo-slide-caption {
        padding: 0.65rem 0.85rem;
        background: #ffffff;
        border-top: 1px solid #f0f2f8;
        display: block;
    }

    .qpteo-slide-title {
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--portal-navy);
        margin: 0 0 0.15rem 0;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .qpteo-slide-desc {
        font-size: 0.76rem;
        color: var(--portal-text-muted);
        margin: 0;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Compact overlay navigation buttons */
    .qpteo-carousel-btn {
        width: 32px;
        height: 32px;
        background: rgba(4, 4, 132, 0.7);
    }

    .qpteo-carousel-btn svg {
        width: 16px;
        height: 16px;
    }

    .qpteo-carousel-btn.prev {
        left: 0.5rem;
        top: 88px;
    }

    .qpteo-carousel-btn.next {
        right: 0.5rem;
        top: 88px;
    }

    /* Move dot indicators closer to image card */
    .qpteo-carousel-indicators {
        margin-top: 0.45rem;
        margin-bottom: 0.75rem;
        gap: 0.4rem;
    }

    .qpteo-carousel-dot {
        width: 7px;
        height: 7px;
    }

    /* --- 3. Quick Actions Row --- */
    .qpteo-quick-actions-section {
        width: 100%;
        padding: 0 0.85rem;
        margin-bottom: 1.15rem;
    }

    .qpteo-quick-actions-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .qpteo-action-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        background: #ffffff;
        border: 1px solid rgba(4, 4, 132, 0.09);
        border-radius: 10px;
        padding: 0.7rem 0.25rem 0.55rem;
        box-shadow: 0 2px 8px rgba(4, 4, 132, 0.05);
        transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .qpteo-action-btn:active {
        transform: scale(0.96);
        background: #fdf3d7;
    }

    .qpteo-action-icon-wrapper {
        width: 38px;
        height: 38px;
        border-radius: 9px;
        background: #fdf3d7;
        color: var(--portal-navy);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 0.35rem;
        transition: background 0.2s ease;
    }

    .qpteo-action-btn:active .qpteo-action-icon-wrapper {
        background: var(--portal-gold);
    }

    .qpteo-action-icon-wrapper svg {
        width: 19px;
        height: 19px;
        stroke: var(--portal-navy);
    }

    .qpteo-action-label {
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--portal-navy);
        text-align: center;
        line-height: 1.2;
    }

    /* --- 4. Content Feed (Recent Memos / Announcements) --- */
    .qpteo-content-feed-section {
        width: 100%;
        padding: 0 0.85rem;
        margin-bottom: 1.5rem;
    }

    .qpteo-feed-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.6rem;
        padding: 0 0.15rem;
    }

    .qpteo-feed-title-wrap {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

    .qpteo-feed-badge-icon {
        width: 15px;
        height: 15px;
        color: var(--portal-gold);
        fill: var(--portal-gold);
    }

    .qpteo-feed-title {
        font-size: 0.92rem;
        font-weight: 700;
        color: var(--portal-navy);
        margin: 0;
        letter-spacing: -0.01em;
    }

    .qpteo-feed-see-all {
        font-size: 0.76rem;
        font-weight: 700;
        color: var(--portal-navy);
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 0.2rem;
        padding: 0.2rem 0.45rem;
        border-radius: 4px;
        background: rgba(4, 4, 132, 0.05);
        transition: background 0.2s ease;
    }

    .qpteo-feed-see-all:active {
        background: var(--portal-gold-pale);
    }

    .qpteo-feed-list {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
    }

    .qpteo-feed-card {
        display: block;
        text-decoration: none;
        background: #ffffff;
        border-radius: 10px;
        padding: 0.75rem 0.85rem;
        border: 1px solid rgba(4, 4, 132, 0.08);
        box-shadow: 0 2px 8px rgba(4, 4, 132, 0.04);
        transition: transform 0.15s ease, box-shadow 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .qpteo-feed-card:active {
        transform: scale(0.985);
        background: #fafbff;
    }

    .qpteo-feed-card-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.3rem;
        gap: 0.5rem;
    }

    .qpteo-feed-card-tag {
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--portal-navy);
        background: var(--portal-gold-pale);
        padding: 0.15rem 0.45rem;
        border-radius: 4px;
        border: 1px solid rgba(237, 172, 54, 0.3);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 65%;
    }

    .qpteo-feed-card-date {
        font-size: 0.7rem;
        color: var(--portal-text-muted);
        font-weight: 500;
        white-space: nowrap;
    }

    .qpteo-feed-card-title {
        font-size: 0.84rem;
        font-weight: 600;
        color: var(--portal-text-dark);
        line-height: 1.35;
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* --- 5. Footer Hierarchy --- */
    .portal-footer {
        padding: 1.25rem 1rem 2rem;
        font-size: 0.74rem;
        line-height: 1.45;
        color: #838996;
    }

    /* --- 6. Repositories Mobile Optimizations --- */
    .repo-section-header {
        margin-bottom: 0.65rem;
    }

    .repo-section-header .portal-section-subtitle {
        font-size: 0.82rem;
        margin-top: 0.15rem;
        color: var(--portal-text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Sticky Dual Dropdown Filter Bar on Mobile */
    .repo-filter-row {
        position: -webkit-sticky;
        position: sticky;
        top: 52px;
        z-index: 50;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 0.4rem 0.15rem;
        border-radius: 10px;
        margin-bottom: 0.75rem;
        display: flex;
        align-items: center;
        gap: 0.45rem;
    }

    .repo-filter-select,
    .portal-picker-btn {
        padding: 0.45rem 0.65rem;
        font-size: 0.75rem;
        height: 38px;
        border-radius: 8px;
    }

    .repo-select-chevron,
    .portal-picker-btn .portal-picker-chevron {
        width: 13px;
        height: 13px;
    }

    .repo-reset-btn {
        width: 36px;
        height: 38px;
        border-radius: 8px;
    }

    /* Toggle Table / Mobile Card Preview Visibility */
    .repo-desktop-table {
        display: none !important;
    }

    .repo-mobile-results {
        display: block !important;
        margin-top: 0.25rem;
    }

    .repo-mobile-results-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.65rem;
        gap: 0.5rem;
    }

    .repo-mobile-results-title {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        font-size: 0.88rem;
        font-weight: 700;
        color: var(--portal-navy);
        white-space: nowrap;
    }

    .repo-mobile-search-bar {
        position: relative;
        display: flex;
        align-items: center;
        flex: 1;
        max-width: 170px;
    }

    .repo-mobile-search-bar input {
        width: 100%;
        height: 30px;
        padding: 0.2rem 2.6rem 0.2rem 0.65rem;
        font-size: 0.74rem;
        border: 1.5px solid var(--portal-border);
        border-radius: 15px;
        background: #ffffff;
        color: var(--portal-text-dark);
        outline: none;
        transition: border-color 0.2s ease;
    }

    .repo-mobile-search-bar input:focus {
        border-color: var(--portal-navy);
    }

    .repo-mobile-search-bar .repo-mobile-search-clear {
        position: absolute;
        right: 1.6rem;
        width: 16px;
        height: 16px;
        background: #e2e8f0;
        border: none;
        border-radius: 50%;
        color: #475569;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }

    .repo-mobile-search-bar .repo-mobile-search-clear:hover,
    .repo-mobile-search-bar .repo-mobile-search-clear:active {
        background: #cbd5e1;
        color: #0f172a;
    }

    .repo-mobile-search-bar .repo-mobile-search-submit {
        position: absolute;
        right: 0.45rem;
        background: none;
        border: none;
        color: var(--portal-navy);
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .repo-mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
    }

    .repo-mobile-doc-card {
        background: #ffffff;
        border-radius: 10px;
        padding: 0.75rem 0.85rem;
        border: 1px solid rgba(4, 4, 132, 0.08);
        box-shadow: 0 2px 8px rgba(4, 4, 132, 0.04);
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
    }

    .repo-doc-card-top {
        display: flex;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .repo-doc-icon-badge {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        margin-top: 0.1rem;
    }

    .repo-doc-card-main {
        flex: 1;
        min-width: 0;
    }

    .repo-doc-title {
        display: block;
        font-size: 0.86rem;
        font-weight: 700;
        color: var(--portal-navy);
        text-decoration: none;
        line-height: 1.3;
        margin-bottom: 0.25rem;
        word-break: break-word;
    }

    .repo-doc-meta-row {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        flex-wrap: wrap;
        font-size: 0.7rem;
        color: var(--portal-text-muted);
    }

    .repo-doc-cat-tag {
        font-weight: 700;
        color: var(--portal-navy);
        background: var(--portal-gold-pale);
        padding: 0.1rem 0.4rem;
        border-radius: 4px;
        border: 1px solid rgba(237, 172, 54, 0.3);
        white-space: nowrap;
        font-size: 0.66rem;
    }

    .repo-doc-meta-dot {
        color: #9ca3af;
        font-size: 0.6rem;
    }

    .repo-doc-date, .repo-doc-size {
        white-space: nowrap;
    }

    .repo-doc-desc {
        font-size: 0.74rem;
        color: var(--portal-text-muted);
        line-height: 1.35;
        margin: 0;
    }

    .repo-doc-card-actions {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        margin-top: 0.15rem;
        padding-top: 0.45rem;
        border-top: 1px solid #f0f2f8;
    }

    .repo-doc-action-btn {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        padding: 0.38rem 0.65rem;
        font-size: 0.74rem;
        font-weight: 700;
        border-radius: 6px;
        text-decoration: none;
        border: 1px solid transparent;
        cursor: pointer;
        transition: all 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .repo-doc-action-btn svg {
        width: 13px;
        height: 13px;
    }

    .repo-doc-action-btn.preview {
        background: rgba(4, 4, 132, 0.06);
        color: var(--portal-navy);
        border-color: rgba(4, 4, 132, 0.15);
    }

    .repo-doc-action-btn.preview:active {
        background: rgba(4, 4, 132, 0.14);
    }

    .repo-doc-action-btn.download {
        background: var(--portal-navy);
        color: #ffffff;
    }

    .repo-doc-action-btn.download:active {
        background: var(--portal-navy-dark);
        transform: scale(0.98);
    }

    /* --- 7. Memorandums Mobile Stacked Cards & Sort Control --- */
    .memo-desktop-table {
        display: none !important;
    }

    .memo-mobile-results {
        display: block !important;
        margin-top: 0.25rem;
    }

    .memo-mobile-toolbar {
        margin-bottom: 0.75rem;
    }

    .memo-mobile-search {
        max-width: 100% !important;
        width: 100% !important;
        margin-bottom: 0.6rem;
    }

    .memo-mobile-search input {
        width: 100%;
        height: 38px;
        padding: 0.4rem 1rem 0.4rem 2.4rem;
        font-size: 0.82rem;
        border: 1.5px solid var(--portal-border);
        border-radius: 8px;
        background: #ffffff;
        color: var(--portal-text-dark);
        outline: none;
    }

    .memo-mobile-search input:focus {
        border-color: var(--portal-navy);
        box-shadow: 0 0 0 3px rgba(4, 4, 132, 0.08);
    }

    .memo-mobile-sub-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .memo-mobile-count {
        font-size: 0.76rem;
        color: var(--portal-text-muted);
        font-weight: 500;
    }

    .memo-sort-wrapper {
        position: relative;
        flex-shrink: 0;
    }

    .memo-sort-label-sr {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .memo-sort-select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-color: #ffffff;
        border: 1.5px solid var(--portal-border);
        border-radius: 8px;
        padding: 0.35rem 1.65rem 0.35rem 0.65rem;
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--portal-navy);
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(4, 4, 132, 0.04);
        transition: all 0.2s ease;
    }

    .memo-sort-select:hover,
    .memo-sort-select:focus {
        border-color: var(--portal-navy);
        outline: none;
    }

    .memo-sort-chevron {
        position: absolute;
        right: 0.45rem;
        top: 50%;
        transform: translateY(-50%);
        width: 13px;
        height: 13px;
        pointer-events: none;
        color: var(--portal-navy);
    }

    .memo-mobile-card-list {
        display: flex;
        flex-direction: column;
        background: #ffffff;
        border-radius: 12px;
        border: 1px solid rgba(4, 4, 132, 0.08);
        box-shadow: 0 2px 10px rgba(4, 4, 132, 0.04);
        overflow: hidden;
    }

    .memo-mobile-card {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid #f0f2f8;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        transition: background 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .memo-mobile-card:last-child {
        border-bottom: none;
    }

    .memo-mobile-card:active {
        background: #fafbff;
    }

    .memo-card-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .memo-card-no {
        font-size: 0.74rem;
        font-weight: 600;
        color: #6b7280;
        letter-spacing: 0.01em;
    }

    .memo-card-date {
        font-size: 0.74rem;
        font-weight: 500;
        color: #6b7280;
        white-space: nowrap;
    }

    .memo-card-subject {
        font-size: 0.88rem;
        font-weight: 700;
        color: var(--portal-navy);
        text-decoration: none;
        line-height: 1.35;
        word-break: break-word;
        display: block;
        transition: color 0.15s ease;
    }

    .memo-card-subject:hover,
    .memo-card-subject:active {
        color: #1d4ed8;
    }
}

/* ---------- Desktop Default Enhancements (>= 769px) ---------- */
@media (min-width: 769px) {
    /* Retain desktop aesthetics and structure cleanly */
    .qpteo-carousel-card {
        width: 100%;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    .qpteo-slide-caption {
        display: none; /* Keep desktop view clean as original */
    }

    .qpteo-quick-actions-section {
        display: none; /* Mobile-focused navigation row */
    }

    .qpteo-content-feed-section {
        display: none; /* Mobile-focused content feed */
    }

    .repo-mobile-results {
        display: none !important;
    }

    .repo-desktop-table {
        display: block !important;
    }

    .memo-mobile-results {
        display: none !important;
    }

    .memo-desktop-table {
        display: block !important;
    }
}
