﻿/*
 * Mobile-First Responsive Stylesheet for MMP Portal
 * Author: GitHub Copilot
 * Last Updated: 2024
 * 
 * Breakpoints:
 * - Mobile: < 576px
 * - Tablet: 576px - 768px
 * - Desktop: > 768px
 * 
 * This stylesheet provides mobile optimizations without affecting desktop behavior.
 * Load this file AFTER custom.css in all layouts.
 */

/* ========================================
   GLOBAL OVERLAY FIX - ALL DEVICES
   Ensure overlay is hidden by default
   ======================================== */

/* Hide overlay by default on all screen sizes */
.sidebar-overlay {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* ========================================
   DESKTOP (> 768px)
   Ensure desktop layout is unaffected
   ======================================== */
@media (min-width: 769px) {
  
  /* Force hide mobile elements on desktop */
  .sidebar-overlay,
  .sidebar-overlay.active,
  .mobile-menu-toggle {
    display: none !important;
  }
  
  /* Ensure sidebar is always visible on desktop */
  .main .sidebar {
    position: static !important;
    left: 0 !important;
  }
}

/* ========================================
   TABLET AND BELOW (≤ 768px)
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        background-color: #fff !important;
    }
  /* === TYPOGRAPHY === */
  body {
    font-size: 14px; /* Slightly larger for better mobile readability */
  }
  
  h1, .h1 { font-size: 1.75rem; }
  h2, .h2 { font-size: 1.5rem; }
  h3, .h3 { font-size: 1.25rem; }
  h4, .h4 { font-size: 1.1rem; }
  h5, .h5 { font-size: 1rem; }
  h6, .h6 { font-size: 0.9rem; }
  
  /* === MAIN LAYOUT (_Layout.cshtml) === */
  .main {
    flex-direction: column;
  }
  
  .main .sidebar {
    position: fixed;
    left: -250px; /* Hidden by default */
    top: 0;
    height: 100vh;
    width: 250px;
    z-index: 1050;
    transition: left 0.3s ease-in-out;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  }
  
  /* Sidebar visible state */
  .main .sidebar.mobile-visible {
    left: 0;
  }
  
  /* Overlay for sidebar - FIXED: Hidden by default */
  .sidebar-overlay {
    display: none !important; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff; /* Plain white, not transparent */
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }
  
  /* Show overlay only when active */
  .sidebar-overlay.active {
    display: block !important;
    pointer-events: auto;
  }
  
  /* Prevent body scroll when menu is open */
  body.menu-open {
    overflow: hidden;
  }
  
  /* Mobile menu toggle button */
  .mobile-menu-toggle {
    display: block;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1060;
    background: #2a587d;
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align icon to the left */
  }
  
  .mobile-menu-toggle i {
    font-size: 20px;
    margin: 0; /* Remove any margin that might center it */
  }
  
  /* Content area takes full width */
  .main .content {
    width: 100%;
    padding-top: 60px; /* Space for mobile menu button */
  }
  
  /* Content header adjustments */
  .main .content .content-header {
    padding: 10px 15px;
  }
  
  .main .content .content-header .heading-block {
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
  }
  
  .main .content .content-header .user-menu h5 {
    font-size: 0.7rem;
  }
  
  /* Content block padding */
  .main .content .content-block {
    padding: 0 10px 20px 10px;
    height: auto;
  }
  
  /* === CARDS === */
  .main .content .content-block .card {
    margin: 0 0 10px 0;
  }
  
  .main .content .content-block .card .card-body .card-title {
    padding: 12px 15px;
  }
  
  .main .content .content-block .card .card-body .card-title h5 {
    font-size: 14px;
  }
  
  .main .content .content-block .card .card-body .form-main {
    padding: 12px 15px 25px 15px;
  }
  
  /* Card 50% height - convert to auto on mobile */
  .card-50-h {
    min-height: auto !important;
  }
  
  /* === GRID LAYOUT ADJUSTMENTS === */
  .row.m-0 > [class*="col-md-"] {
    margin-bottom: 15px;
  }
  
  /* Stack columns vertically on mobile */
  .col-md-7,
  .col-md-6,
  .col-md-5,
  .col-md-4,
  .col-md-3 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    padding-left: 0;
    padding-right: 0;
  }
  
  /* === QUICK LINKS === */
  .row-link .col-link {
    border-right: none !important;
    border-bottom: solid 1px #F3F4F5;
  }
  
  .row-link .col-link:last-child {
    border-bottom: none;
  }
  
  .row-link .col-link .link-block {
    padding: 20px 10px;
  }
  
  .row-link .col-link .link-block a p {
    font-size: 12px;
  }
  
  .row-link .col-link .link-block a img {
    max-width: 35px;
  }
  
  /* === TABLES === */
  .main .content .content-block .card .card-body .table-block {
    padding: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }
  
  .main .content .content-block .card .card-body .table-block .custom-table,
  .main .content .content-block .card .card-body .table-block .inner-table {
    min-width: 600px; /* Force horizontal scroll */
  }
  
  .main .content .content-block .card .card-body .table-block .custom-table tbody tr td,
  .main .content .content-block .card .card-body .table-block .inner-table tbody tr td {
    font-size: 12px;
    padding: 8px 5px;
  }
  
  /* Small table optimizations */
  .small-table-block .small-table tr th,
  .small-table-block .small-table tr td {
    padding: 8px 5px;
    font-size: 12px;
  }
  
  /* Filter table */
  .filter-table tr th,
  .filter-table tr td {
    font-size: 11px;
    padding: 8px 5px !important;
  }
  
  .filter-table thead tr.filters th input {
    padding: 8px;
    font-size: 12px;
  }
  
  /* === NAVIGATION TABS === */
  .nav-tabs .nav-link {
    font-size: 12px !important;
    padding: 10px 12px !important;
  }
  
  .card-table-block .nav-tabs .nav-item button {
    padding: 12px 15px !important;
  }
  
  /* === MODALS === */
  .modal .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100vh;
  }
  
  .modal .modal-dialog .modal-content {
    height: 100vh;
    border-radius: 0;
  }
  
  .modal .modal-dialog .modal-content .modal-header {
    padding: 15px;
  }
  
  .modal .modal-dialog .modal-content .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal .modal-dialog .modal-content .modal-footer {
    padding: 15px;
  }
  
  .modal .modal-dialog .modal-content .modal-footer .btn {
    padding: 10px 15px;
    font-size: 13px;
  }
  
  #idCardModal .modal-body {
    height: auto !important;
    min-height: 400px;
  }
  
  #idCardModal .modal-body iframe {
    height: 400px !important;
  }
  
  /* === FORMS === */
  .form-control,
  .input-style,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
    min-height: 44px; /* Touch-friendly minimum */
    padding: 10px 12px;
  }
  
  .btn,
  button {
    min-height: 44px; /* Touch-friendly buttons */
    padding: 10px 20px;
    font-size: 14px;
  }
  
  /* === KENDO GRID === */
  .k-grid {
    font-size: 12px;
  }
  
  .k-grid-header th.k-header > .k-link {
    font-size: 11px !important;
  }
  
  .k-grid td {
    font-size: 11px !important;
    padding: 8px 5px;
  }
  
  .k-pager-wrap {
    font-size: 12px;
  }
  
  .k-pager-wrap .k-link {
    padding: 5px 8px;
    font-size: 11px !important;
  }
  
  /* === KENDO GRID MOBILE OPTIMIZATIONS === */
  
  /* Make grid container scrollable horizontally */
  .k-grid {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    display: block !important;
  }
  
  /* Grid table should maintain minimum width for readability */
  .k-grid table {
    min-width: 600px; /* Ensures horizontal scroll for better data visibility */
  }
  
  /* Header styling for mobile */
  .k-grid-header {
    border-bottom: 2px solid #2a587d !important;
  }
  
  .k-grid-header th.k-header {
    white-space: nowrap;
    font-size: 11px !important;
    padding: 10px 6px !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  
  /* Content rows */
  .k-grid-content {
    max-height: 400px; /* Limit height on mobile for better UX */
    overflow-y: auto;
  }
  
  .k-grid tbody tr {
    border-bottom: 1px solid #e0e0e0;
  }
  
  .k-grid tbody tr:hover {
    background-color: rgba(42, 88, 125, 0.05);
  }
  
  .k-grid tbody td {
    white-space: nowrap;
    font-size: 11px !important;
    padding: 12px 10px !important; /* Increased padding for better spacing */
    vertical-align: middle;
  }
  
  /* Header cells - add padding */
  .k-grid-header th.k-header {
    white-space: nowrap;
    font-size: 11px !important;
    padding: 12px 10px !important; /* Increased padding to match body cells */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  
  /* Action buttons in grid */
  .k-grid .btn {
    font-size: 10px !important;
    padding: 6px 10px !important;
    min-height: 32px !important;
    white-space: nowrap;
    display: inline-flex !important; /* Changed to inline-flex for better centering */
    align-items: center;
    justify-content: center;
    line-height: 1.2;
  }
  
  .k-grid .btn-xs {
    font-size: 10px !important;
    padding: 5px 8px !important;
    min-height: 28px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  
  /* Pager optimizations for mobile */
  .k-pager-wrap {
    padding: 8px 5px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
  
  .k-pager-wrap .k-pager-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
  }
  
  .k-pager-wrap .k-link,
  .k-pager-wrap .k-state-selected {
    min-width: 32px;
    min-height: 32px;
    padding: 6px 8px !important;
    font-size: 11px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px;
  }
  
  /* Page size dropdown */
  .k-pager-wrap .k-dropdown {
    font-size: 11px !important;
    min-height: 32px;
  }
  
  .k-pager-wrap select.k-dropdown {
    padding: 5px 8px;
    font-size: 11px !important;
  }
  
  /* Pager info text */
  .k-pager-info {
    font-size: 10px !important;
    padding: 5px;
    width: 100%;
    text-align: center;
    order: -1; /* Show at top on mobile */
  }
  
  /* Hide less important pager elements on very small screens */
  .k-pager-wrap .k-pager-sizes {
    display: none; /* Hide page size selector on mobile */
  }
  
  /* Grid toolbar */
  .k-grid-toolbar {
    padding: 8px;
    flex-wrap: wrap;
  }
  
  .k-grid-toolbar .k-button {
    font-size: 11px !important;
    padding: 8px 12px !important;
    margin: 3px;
    min-height: 36px;
  }
  
  /* Sortable column indicators */
  .k-grid-header .k-i-sort-asc-sm,
  .k-grid-header .k-i-sort-desc-sm {
    font-size: 10px;
  }
  
  /* Filter menu */
  .k-filter-menu {
    max-width: 90vw;
  }
  
  /* Mobile scroll indicator removed - was causing unwanted display */
  
  /* Hide scroll indicator after user scrolls */
  .k-grid.scrolled::after {
    display: none;
  }
}

/* ========================================
   MOBILE ONLY (? 576px)
   ======================================== */
@media (max-width: 576px) {
  
  /* Even smaller typography for very small screens */
  body {
    font-size: 13px;
  }
  
  /* Sidebar adjustments */
  .main .sidebar {
    width: 220px;
    left: -220px;
  }
  
  .main .sidebar .sidebar-logo {
    padding: 20px 15px;
  }
  
  .main .sidebar .sidebar-logo img {
    max-width: 60px;
    height: auto;
  }
  
  .main .sidebar h5 {
    font-size: 0.8rem;
  }
  
  .main .sidebar .sidebar-menu .menu ul li a {
    font-size: 0.65rem;
    padding: 8px 12px;
  }
  
  .main .sidebar .sidebar-menu .menu ul li a img {
    max-width: 18px;
  }
  
  /* Content adjustments */
  .main .content .content-block {
    padding: 0 5px 15px 5px;
  }
  
  /* Card adjustments */
  .main .content .content-block .card .card-body .card-title {
    padding: 10px;
  }
  
  .main .content .content-block .card .card-body .form-main {
    padding: 10px;
  }
  
  /* Button stacking */
  .button-wrapper {
    flex-direction: column;
  }
  
  .button-wrapper .sign-in-discard-button,
  .button-wrapper .sign-in-block {
    width: 100% !important;
    margin: 5px 0 !important;
  }
  
  /* Table font size reduction */
  .main .content .content-block .card .card-body .table-block .custom-table tbody tr td,
  .main .content .content-block .card .card-body .table-block .inner-table tbody tr td {
    font-size: 11px;
  }
  
  /* Navigation tabs */
  .nav-tabs .nav-link {
    font-size: 11px !important;
    padding: 8px 10px !important;
  }
  
  /* Kendo grid - even more compact for small mobile */
  .k-grid td,
  .k-grid-header th.k-header > .k-link {
    font-size: 10px !important;
  }
  
  .k-grid td {
    padding: 10px 8px !important; /* Adjusted padding for small mobile */
  }
  
  .k-grid-header th.k-header {
    padding: 10px 8px !important; /* Adjusted padding for small mobile */
  }
  
  /* Kendo grid buttons - smaller on small mobile */
  .k-grid .btn {
    font-size: 9px !important;
    padding: 4px 6px !important;
    min-height: 28px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  
  /* Kendo pager - more compact */
  .k-pager-wrap .k-link,
  .k-pager-wrap .k-state-selected {
    min-width: 28px;
    min-height: 28px;
    padding: 4px 6px !important;
    font-size: 10px !important;
  }
  
  .k-pager-info {
    font-size: 9px !important;
  }
  
  /* Hide page numbers, show only prev/next on very small screens */
  .k-pager-numbers-wrap {
    display: none !important;
  }
  
  .k-pager-wrap .k-pager-nav {
    display: inline-flex !important;
    gap: 5px;
  }
  
  /* User menu */
  .main .content .content-header .user-menu h5 {
    font-size: 0.65rem;
  }
  
  /* Quick links - single column */
  .row-link {
    flex-direction: column;
  }
  
  .row-link .col-link {
    width: 100%;
  }
  
  /* Grid container max width on small screens */
  #grid,
  .k-grid {
    max-width: 100vw;
    margin-left: -5px;
    margin-right: -5px;
  }
}

/* ========================================
   LOGIN LAYOUT (_LoginLayout.cshtml)
   ======================================== */
@media (max-width: 768px) {
  
  /* Stack login layout vertically */
  .login-main-block .row {
    flex-direction: column;
  }
  
  .login-main-block .col-md-6 {
    width: 100%;
    max-width: 100%;
  }
  
  /* Hide or minimize left panel on mobile */
  .login-main-block .left-login-block {
    display: none; /* Hide decorative panel on mobile */
  }
  
  /* Adjust form block */
  .login-main-block .form-block-main {
    min-height: 100vh;
    padding: 20px;
  }
  
  .login-main-block .form-block-main .form-block-sub {
    max-width: 100%;
  }
  
  .login-main-block .heading-logo img {
    max-width: 70px;
  }
  
  .login-main-block .heading-logo p {
    font-size: 12px;
  }
  
  .login-main-block .Welcome-heading {
    margin-top: 20px;
    margin-bottom: 20px;
  }
  
  .login-main-block .Welcome-heading h3 {
    font-size: 18px;
  }
  
  .login-main-block .sign-up-block {
    margin-top: 15px;
  }
  
  /* Touch-friendly inputs */
  .login-main-block .input-style {
    font-size: 16px !important;
    min-height: 44px;
  }
  
  .login-main-block .sign-in-block {
    min-height: 44px;
    font-size: 15px;
  }
  
  /* App buttons */
  .login-main-block .app-link {
    flex-direction: column;
  }
  
  .login-main-block .app-link .app-button {
    width: 100%;
    margin: 10px 0;
  }
}

@media (max-width: 576px) {
  .login-main-block .form-block-main {
    padding: 15px;
  }
  
  .login-main-block .Welcome-heading h3 {
    font-size: 16px;
  }
}

/* ========================================
   ADMIN LAYOUT (_AdminLayoutPage.cshtml)
   ======================================== */
@media (max-width: 768px) {
  
  /* Stack title header */
  .title-header .full-header {
    flex-direction: column;
  }
  
  .title-header-sub-main,
  .title-header-menu {
    width: 100%;
  }
  
  .title-header-sub {
    flex-direction: column;
    padding: 10px;
  }
  
  .title-header-sub a img {
    max-width: 60px !important;
  }
  
  .title-header h5 {
    font-size: 14px;
    padding: 5px 10px;
  }
  
  .title-header-menu {
    justify-content: space-between;
    padding: 10px 15px;
  }
  
  .title-header-menu .user-menu h6 {
    font-size: 12px;
  }
  
  /* Navigation */
  .navigation {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .navigation .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  
  .navigation .nav ul {
    display: flex;
    flex-wrap: nowrap;
    padding: 0;
  }
  
  .navigation .nav ul li {
    white-space: nowrap;
  }
  
  .navigation .nav ul li a {
    font-size: 12px;
    padding: 10px 15px;
  }
  
  /* Form block */
  .form-block {
    padding: 0;
  }
}

@media (max-width: 576px) {
  .title-header h5 {
    font-size: 12px;
  }
  
  .navigation .nav ul li a {
    font-size: 11px;
    padding: 8px 12px;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
@media (max-width: 768px) {
  
  /* Mobile-only display utilities */
  .mobile-only {
    display: block !important;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  /* Text alignment */
  .text-mobile-center {
    text-align: center !important;
  }
  
  /* Padding/Margin utilities */
  .p-mobile-0 { padding: 0 !important; }
  .p-mobile-10 { padding: 10px !important; }
  .p-mobile-15 { padding: 15px !important; }
  
  .m-mobile-0 { margin: 0 !important; }
  .m-mobile-10 { margin: 10px !important; }
  .m-mobile-15 { margin: 15px !important; }
  
  /* Width utilities */
  .w-mobile-100 { width: 100% !important; }
    body > div.main > div.sidebar.mobile-visible {
        min-width: 350px !important;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  
  /* Reduce vertical spacing in landscape */
  .main .content .content-block .card {
    margin: 0 0 8px 0;
  }
  
  .main .content .content-block .card .card-body .card-title {
    padding: 8px 15px;
  }
  
  /* Sidebar full height in landscape */
  .main .sidebar {
    height: 100vh;
    overflow-y: auto;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  
  /* Hide navigation and non-essential elements */
  .main .sidebar,
  .mobile-menu-toggle,
  .sidebar-overlay,
  .main .content .content-header,
  .btn,
  .nav-tabs,
  .modal,
  .k-pager-wrap {
    display: none !important;
  }
  
  /* Expand content to full width */
  .main .content {
    width: 100%;
    padding: 0;
  }
  
  .main .content .content-block {
    padding: 0;
  }
  
  /* Ensure tables print properly */
  .main .content .content-block .card .card-body .table-block {
    overflow: visible;
  }
  
  .main .content .content-block .card .card-body .table-block .custom-table,
  .main .content .content-block .card .card-body .table-block .inner-table {
    min-width: auto;
  }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */
@media (max-width: 768px) {
  
  /* Larger tap targets for accessibility */
  a, button, .btn, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Focus styles for keyboard navigation */
  a:focus,
  button:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline: 2px solid #2a587d;
    outline-offset: 2px;
  }
}
