/*
 * ========================================
 * MOBILE RESPONSIVE STYLES FOR GMS
 * Comprehensive mobile-first responsive design
 * ========================================
 */

/* ========================================
   BASE MOBILE STYLES
   ======================================== */

/* Ensure smooth scrolling on mobile */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    width: 100%;
}

/* Touch-friendly tap targets (minimum 44px) */
a, button, input[type="submit"], input[type="button"], .btn {
    min-height: 44px;
    min-width: 44px;
}

/* Better touch feedback */
a:active, button:active, .btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* ========================================
   MOBILE NAVIGATION (< 992px)
   ======================================== */

@media (max-width: 991px) {
    /* Mobile Header */
    header.header_four {
        position: sticky;
        top: 0;
        z-index: 9999;
    }
    
    /* Hide desktop navigation */
    header .edu_nav nav {
        display: block !important;
    }
    
    /* Mobile Logo */
    .navbar-brand,
    .logo {
        max-width: 120px !important;
        height: auto !important;
    }
    
    .logo img {
        max-width: 100%;
        height: auto;
    }
    
    /* Hamburger Menu Button */
    .navbar-toggler {
        display: block !important;
        border: 2px solid var(--primary-color, #28a745) !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
        background: #fff !important;
        position: relative;
        z-index: 1001;
    }
    
    .navbar-toggler:focus {
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.25) !important;
    }
    
    .navbar-toggler-icon {
        width: 24px;
        height: 24px;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%2328a745' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    }
    
    /* Mobile Menu Container */
    .navbar-collapse {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        background: #fff !important;
        padding: 80px 0 20px !important;
        box-shadow: 5px 0 25px rgba(0,0,0,0.15) !important;
        transition: left 0.3s ease-in-out !important;
        overflow-y: auto !important;
        z-index: 1000 !important;
    }
    
    .navbar-collapse.show,
    .navbar-collapse.collapsing {
        left: 0 !important;
    }
    
    /* Mobile Menu Overlay */
    .navbar-collapse::before {
        content: '';
        position: fixed;
        top: 0;
        left: 100%;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .navbar-collapse.show::before {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Mobile Nav Items */
    .navbar-nav {
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    .navbar-nav .nav-item {
        width: 100% !important;
        border-bottom: 1px solid #eee !important;
    }
    
    .navbar-nav .nav-link {
        padding: 15px 20px !important;
        font-size: 16px !important;
        color: #333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:focus {
        background: #f8f9fa !important;
        color: var(--primary-color, #28a745) !important;
    }
    
    /* Mobile Dropdown */
    .navbar-nav .dropdown-menu {
        position: static !important;
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        background: #f8f9fa !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: none !important;
    }
    
    .navbar-nav .dropdown.show .dropdown-menu,
    .navbar-nav .dropdown-menu.show {
        display: block !important;
    }
    
    .navbar-nav .dropdown-item {
        padding: 12px 20px 12px 40px !important;
        font-size: 15px !important;
        border-bottom: 1px solid #e9ecef !important;
    }
    
    .navbar-nav .dropdown-item:hover {
        background: #e9ecef !important;
        color: var(--primary-color, #28a745) !important;
    }
    
    /* Dropdown Arrow */
    .navbar-nav .dropdown-toggle::after {
        float: right !important;
        margin-top: 8px !important;
        transition: transform 0.3s ease !important;
    }
    
    .navbar-nav .dropdown.show .dropdown-toggle::after {
        transform: rotate(180deg) !important;
    }
    
    /* Header Top Bar Mobile */
    .header_top {
        padding: 10px 0 !important;
    }
    
    .header_top .info_wrapper {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px !important;
    }
    
    .header_top .contact_info {
        display: none !important;
    }
    
    .header_top .login_info {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Mean Menu Override */
    .mean-container .mean-bar {
        background: transparent !important;
        min-height: auto !important;
        padding: 0 !important;
    }
    
    .mean-container .mean-nav {
        background: #fff !important;
        margin-top: 10px !important;
    }
    
    .mean-container a.meanmenu-reveal {
        color: var(--primary-color, #28a745) !important;
        border: 2px solid var(--primary-color, #28a745) !important;
        border-radius: 6px !important;
        padding: 8px 10px !important;
        background: #fff !important;
    }
    
    .mean-container a.meanmenu-reveal span {
        background: var(--primary-color, #28a745) !important;
    }
}

/* ========================================
   TABLET STYLES (768px - 991px)
   ======================================== */

@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px !important;
    }
    
    /* Two column layout for cards */
    .row > [class*="col-md-4"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* Statistics cards */
    .stat-card {
        margin-bottom: 20px;
    }
    
    /* Forms side by side */
    .form-row > .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ========================================
   MOBILE STYLES (< 768px)
   ======================================== */

@media (max-width: 767px) {
    /* Container full width with padding */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        max-width: 100% !important;
    }
    
    /* Stack all columns */
    .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    /* Typography adjustments */
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    h5, h6 { font-size: 1rem !important; }
    
    p {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }
    
    /* Slider/Hero Section */
    .rev_slider_wrapper,
    .slider-section,
    .hero-section {
        min-height: 300px !important;
        height: auto !important;
    }
    
    .rev_slider {
        min-height: 300px !important;
    }
    
    .rev_slider li {
        min-height: 300px !important;
    }
    
    .tp-caption h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    .tp-caption p {
        font-size: 0.9rem !important;
    }
    
    /* Statistics Section */
    .statistics_section {
        padding: 40px 0 !important;
    }
    
    .stat-card {
        margin-bottom: 20px !important;
        padding: 1.5rem !important;
    }
    
    .stat-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }
    
    .stat-number {
        font-size: 2rem !important;
    }
    
    .stat-text {
        font-size: 0.95rem !important;
    }
    
    /* Welcome Section */
    .welcome-section {
        padding: 40px 0 !important;
    }
    
    .welcome-content h2 {
        font-size: 1.5rem !important;
    }
    
    /* Buttons */
    .btn {
        width: 100% !important;
        padding: 12px 20px !important;
        font-size: 1rem !important;
        margin-bottom: 10px !important;
    }
    
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    /* Cards */
    .card {
        margin-bottom: 20px !important;
    }
    
    .card-body {
        padding: 1.25rem !important;
    }
    
    /* Footer */
    footer {
        padding: 30px 0 15px !important;
    }
    
    footer .footer_top h3 {
        margin-top: 30px !important;
        margin-bottom: 15px !important;
    }
    
    footer .footer_single_col {
        margin-bottom: 20px !important;
    }
    
    /* Hide non-essential elements */
    .d-none-mobile {
        display: none !important;
    }
}

/* ========================================
   SMALL MOBILE STYLES (< 480px)
   ======================================== */

@media (max-width: 479px) {
    /* Extra small adjustments */
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.35rem !important; }
    
    /* Smaller buttons */
    .btn {
        padding: 10px 15px !important;
        font-size: 0.9rem !important;
    }
    
    /* Slider text */
    .tp-caption h2 {
        font-size: 1.25rem !important;
    }
    
    /* Statistics */
    .stat-number {
        font-size: 1.75rem !important;
    }
}

/* ========================================
   RESPONSIVE FORMS
   ======================================== */

@media (max-width: 767px) {
    /* Form containers */
    .form-full-box,
    .register_area .form-full-box {
        margin: 0 !important;
        padding: 20px 15px !important;
        border-radius: 8px !important;
    }
    
    /* Form groups */
    .form-group {
        margin-bottom: 15px !important;
    }
    
    /* Form labels */
    .form-label,
    label {
        font-size: 0.9rem !important;
        margin-bottom: 5px !important;
    }
    
    /* Form inputs */
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
        width: 100% !important;
        padding: 12px 15px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border-radius: 6px !important;
        min-height: 48px !important;
    }
    
    /* Select dropdowns */
    select.form-control {
        padding-right: 35px !important;
    }
    
    /* Textarea */
    textarea.form-control {
        min-height: 120px !important;
    }
    
    /* Form rows - stack on mobile */
    .form-row,
    .row.form-group {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .form-row > [class*="col-"],
    .row.form-group > [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 15px !important;
    }
    
    /* Checkbox and Radio */
    .form-check {
        padding-left: 25px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    .form-check-input {
        width: 20px !important;
        height: 20px !important;
        margin-top: 0 !important;
    }
    
    .form-check-label {
        font-size: 0.95rem !important;
        padding-left: 8px !important;
    }
    
    /* Submit buttons */
    input[type="submit"],
    button[type="submit"] {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
    }
    
    /* Registration form specific */
    .register_area {
        padding: 60px 0 40px !important;
    }
    
    .register_area .form-content {
        padding: 40px 15px 0 !important;
    }
    
    .register_area .form-content h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    /* Login modal */
    .login_signup_option .login_modal_body {
        width: 95% !important;
        max-width: 400px !important;
        margin: 20px auto !important;
        padding: 20px !important;
    }
    
    .login_signup_option .tab-content {
        padding: 15px !important;
    }
}

/* ========================================
   RESPONSIVE TABLES
   ======================================== */

@media (max-width: 767px) {
    /* Table wrapper for horizontal scroll */
    .table-responsive {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Card-style tables on mobile */
    .table-mobile-cards {
        display: block !important;
    }
    
    .table-mobile-cards thead {
        display: none !important;
    }
    
    .table-mobile-cards tbody {
        display: block !important;
    }
    
    .table-mobile-cards tr {
        display: block !important;
        margin-bottom: 15px !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
        padding: 15px !important;
        background: #fff !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    }
    
    .table-mobile-cards td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 0 !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
    }
    
    .table-mobile-cards td:last-child {
        border-bottom: none !important;
    }
    
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #333;
        flex: 0 0 40%;
        text-align: left;
    }
    
    /* Standard table adjustments */
    table {
        font-size: 0.85rem !important;
    }
    
    table th,
    table td {
        padding: 10px 8px !important;
        white-space: nowrap !important;
    }
    
    /* Action buttons in tables */
    table .btn,
    table .btn-sm {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        min-height: 32px !important;
        min-width: auto !important;
        width: auto !important;
        margin: 2px !important;
    }
}

/* ========================================
   RESPONSIVE MODALS
   ======================================== */

@media (max-width: 767px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-content {
        border-radius: 12px !important;
    }
    
    .modal-header {
        padding: 15px 20px !important;
    }
    
    .modal-body {
        padding: 20px !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
    }
    
    .modal-footer {
        padding: 15px 20px !important;
        flex-direction: column !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        margin: 5px 0 !important;
    }
}

/* ========================================
   DASHBOARD MOBILE STYLES
   ======================================== */

@media (max-width: 991px) {
    /* Sidebar */
    .sidebar-menu,
    .left-sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
    }
    
    .sidebar-menu.active,
    .left-sidebar.active {
        left: 0 !important;
    }
    
    /* Main content full width */
    .main-content,
    .content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Dashboard cards */
    .dashboard-card,
    .widget-card {
        margin-bottom: 15px !important;
    }
    
    /* Sidebar toggle button */
    .sidebar-toggle {
        display: block !important;
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        width: 50px !important;
        height: 50px !important;
        background: var(--primary-color, #28a745) !important;
        color: #fff !important;
        border: none !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
        z-index: 9998 !important;
        font-size: 1.25rem !important;
    }
}

@media (max-width: 767px) {
    /* Dashboard header */
    .dashboard-header,
    .page-header {
        padding: 15px !important;
    }
    
    .dashboard-header h1,
    .page-header h1 {
        font-size: 1.25rem !important;
    }
    
    /* Dashboard stats */
    .dashboard-stats .stat-item {
        padding: 15px !important;
        margin-bottom: 10px !important;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.85rem !important;
        padding: 10px 15px !important;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    .pagination .page-link {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }
}

/* ========================================
   PROPOSAL FORM MOBILE STYLES
   ======================================== */

@media (max-width: 767px) {
    /* Tab navigation */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        border-bottom: 2px solid #dee2e6 !important;
    }
    
    .nav-tabs .nav-item {
        flex-shrink: 0 !important;
    }
    
    .nav-tabs .nav-link {
        padding: 10px 15px !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }
    
    /* Progress steps */
    .progress-steps,
    .step-indicator {
        overflow-x: auto !important;
        padding-bottom: 10px !important;
    }
    
    .progress-steps .step {
        min-width: 80px !important;
        font-size: 0.75rem !important;
    }
    
    /* File upload */
    .file-upload-wrapper {
        padding: 20px !important;
    }
    
    .file-upload-wrapper input[type="file"] {
        width: 100% !important;
    }
    
    /* Budget table */
    .budget-table input[type="number"] {
        width: 100% !important;
        min-width: 80px !important;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile,
    .d-mobile-none {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .hide-tablet,
    .d-tablet-none {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 992px) {
    .hide-desktop,
    .d-desktop-none {
        display: none !important;
    }
    
    /* Show only on mobile/tablet */
    .mobile-only,
    .d-mobile-only {
        display: none !important;
    }
}

/* Show only on mobile */
@media (max-width: 767px) {
    .mobile-only,
    .d-mobile-only {
        display: block !important;
    }
}

/* Text alignment utilities */
@media (max-width: 767px) {
    .text-mobile-center {
        text-align: center !important;
    }
    
    .text-mobile-left {
        text-align: left !important;
    }
}

/* Spacing utilities for mobile */
@media (max-width: 767px) {
    .mt-mobile-0 { margin-top: 0 !important; }
    .mb-mobile-0 { margin-bottom: 0 !important; }
    .mt-mobile-3 { margin-top: 1rem !important; }
    .mb-mobile-3 { margin-bottom: 1rem !important; }
    .pt-mobile-0 { padding-top: 0 !important; }
    .pb-mobile-0 { padding-bottom: 0 !important; }
    .pt-mobile-3 { padding-top: 1rem !important; }
    .pb-mobile-3 { padding-bottom: 1rem !important; }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */

/* Disable hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none !important;
    }
    
    /* Larger touch targets */
    .nav-link,
    .dropdown-item,
    .list-group-item {
        padding: 12px 16px !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Hide navigation and non-essential elements */
    header,
    footer,
    .sidebar-menu,
    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }
    
    /* Full width content */
    .main-content,
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Ensure text is readable */
    body {
        font-size: 12pt !important;
        color: #000 !important;
        background: #fff !important;
    }
    
    /* Show URLs for links */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION FIXES
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    /* Reduce header height */
    header {
        padding: 5px 0 !important;
    }
    
    /* Smaller slider */
    .rev_slider_wrapper {
        min-height: 200px !important;
    }
    
    /* Modal adjustments */
    .modal-body {
        max-height: 60vh !important;
    }
}

/* ========================================
   iOS SPECIFIC FIXES
   ======================================== */

/* Fix for iOS input zoom */
@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Fix for iOS momentum scrolling */
.scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Fix for iOS safe area (notch) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .fixed-bottom {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}
