/**
 * NEXUS Property OS - Mobile Responsiveness Stylesheet
 * Comprehensive mobile-first responsive design
 */

/* ===================================
   CSS Variables for Mobile
   =================================== */
:root {
    --mobile-padding: 1rem;
    --tablet-padding: 1.5rem;
    --touch-target-min: 44px;
    --safe-area-inset-top: env(safe-area-inset-top, 0);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
    --safe-area-inset-left: env(safe-area-inset-left, 0);
    --safe-area-inset-right: env(safe-area-inset-right, 0);
}

/* ===================================
   Base Mobile Resets
   =================================== */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly inputs */
input, button, select, textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* ===================================
   Large Tablets & Small Desktops
   =================================== */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    nav {
        padding: 0 1.5rem;
    }

    .nav-links {
        gap: 1.5rem;
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pricing-grid {
        gap: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===================================
   Tablets (768px - 1024px)
   =================================== */
@media (max-width: 1024px) {
    .hero {
        padding: 6rem 1.5rem 4rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .section {
        padding: 4rem 1.5rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .pricing-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pricing-card.featured {
        transform: scale(1.02);
    }

    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Dashboard layouts */
    .dashboard-sidebar {
        width: 240px;
    }

    .dashboard-main {
        margin-left: 240px;
    }

    /* Table scroll on tablets */
    .table-responsive-tablet {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===================================
   Small Tablets & Large Phones (768px)
   =================================== */
@media (max-width: 768px) {
    /* Navigation */
    .nav-links {
        display: none !important;
    }

    .mobile-menu-btn {
        display: flex !important;
    }

    nav {
        padding: 0 var(--mobile-padding);
    }

    /* Hero Section */
    .hero {
        padding: 5rem var(--mobile-padding) 3rem;
    }

    .hero h1 {
        font-size: 2rem;
        line-height: 1.2;
    }

    .hero p {
        font-size: 1rem;
    }

    .hero-badge {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
    }

    .hero-cta {
        flex-direction: column;
        align-items: center;
    }

    .hero-cta .btn-hero-primary,
    .hero-cta .btn-hero-secondary {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }

    .hero-stats {
        gap: 1.5rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Sections */
    .section {
        padding: 3rem var(--mobile-padding);
    }

    .section-title {
        font-size: 1.75rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
    }

    /* Grids */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .pricing-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .pricing-card.featured {
        transform: none;
    }

    .pricing-card.featured:hover {
        transform: translateY(-5px);
    }

    .testimonials-grid {
        grid-template-columns: 1fr;
    }

    /* Dashboard */
    .dashboard-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .dashboard-sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .dashboard-main {
        margin-left: 0;
        width: 100%;
    }

    .dashboard-header {
        padding: 1rem;
    }

    .dashboard-toggle-btn {
        display: flex !important;
    }

    /* Cards */
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .card {
        margin-bottom: 1rem;
    }

    /* Tables */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        min-width: 600px;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        width: 100%;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    /* Buttons */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }

    /* Trust logos */
    .trust-logos {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .trust-logo {
        width: 80px;
    }

    /* CTA Section */
    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-cta {
        width: 100%;
        max-width: 300px;
    }
}

/* ===================================
   Mobile Phones (576px and below)
   =================================== */
@media (max-width: 576px) {
    /* Typography */
    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    h3, .h3 {
        font-size: 1.25rem;
    }

    /* Hero */
    .hero {
        padding: 4rem var(--mobile-padding) 2.5rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .stat-item {
        flex: 0 0 45%;
    }

    /* Cards */
    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .feature-card {
        padding: 1.25rem;
    }

    .feature-card h3 {
        font-size: 1rem;
    }

    .feature-card p {
        font-size: 0.9rem;
    }

    /* Pricing */
    .pricing-card {
        padding: 1.5rem;
    }

    .pricing-price {
        font-size: 2rem;
    }

    /* Forms */
    .form-control {
        padding: 0.75rem 1rem;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group .form-control {
        border-radius: 8px !important;
        margin-bottom: 0.5rem;
    }

    .input-group .btn {
        border-radius: 8px !important;
        width: 100%;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 1rem 1.5rem;
    }

    /* Dashboard specific */
    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-number {
        font-size: 1.5rem;
    }

    .stat-card .stat-label {
        font-size: 0.75rem;
    }

    /* Tables on mobile - Card view */
    .mobile-card-view thead {
        display: none;
    }

    .mobile-card-view tbody tr {
        display: block;
        padding: 1rem;
        margin-bottom: 1rem;
        background: rgba(26, 41, 66, 0.5);
        border-radius: 8px;
        border: 1px solid rgba(212, 175, 55, 0.1);
    }

    .mobile-card-view tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .mobile-card-view tbody td:last-child {
        border-bottom: none;
    }

    .mobile-card-view tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #94a3b8;
    }

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

    .modal-body {
        padding: 1rem;
    }

    /* Tabs */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* ===================================
   Extra Small Devices (Below 375px)
   =================================== */
@media (max-width: 375px) {
    :root {
        --mobile-padding: 0.75rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }

    .stat-item {
        flex: 0 0 100%;
    }

    .feature-card {
        padding: 1rem;
    }

    .pricing-price {
        font-size: 1.75rem;
    }
}

/* ===================================
   Touch Device Optimizations
   =================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn, button,
    .nav-link,
    .dropdown-item,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
    }

    /* Remove hover effects on touch */
    .btn:hover,
    .card:hover,
    .feature-card:hover,
    .pricing-card:hover {
        transform: none;
    }

    /* Add active state for touch feedback */
    .btn:active,
    .card:active,
    .feature-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    /* Larger dropdown items */
    .dropdown-item {
        padding: 0.75rem 1rem;
    }

    /* Scrollbar hide on touch */
    ::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
}

/* ===================================
   Landscape Mobile Orientation
   =================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding: 2rem var(--mobile-padding);
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .hero-stats {
        display: none;
    }

    .section {
        padding: 2rem var(--mobile-padding);
    }

    /* Fixed header smaller */
    header {
        padding: 0.5rem 0;
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo-icon {
        width: 35px;
        height: 35px;
    }

    /* Mobile nav adjustments */
    .mobile-nav {
        overflow-y: auto;
        max-height: 100vh;
    }
}

/* ===================================
   Safe Area Support (Notch/Home Bar)
   =================================== */
@supports (padding: max(0px)) {
    body {
        padding-left: max(var(--mobile-padding), var(--safe-area-inset-left));
        padding-right: max(var(--mobile-padding), var(--safe-area-inset-right));
    }

    header {
        padding-top: max(0.5rem, var(--safe-area-inset-top));
    }

    footer {
        padding-bottom: max(1rem, var(--safe-area-inset-bottom));
    }

    .mobile-nav {
        padding-left: var(--safe-area-inset-left);
        padding-right: var(--safe-area-inset-right);
    }
}

/* ===================================
   Mobile Navigation Styles
   =================================== */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    border-radius: 8px;
    transition: background 0.3s;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus {
    background: rgba(212, 175, 55, 0.1);
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 320px;
    height: 100vh;
    background: linear-gradient(180deg, #1a2942 0%, #0A1628 100%);
    z-index: 1002;
    transition: right 0.3s ease;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.mobile-nav-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s;
}

.mobile-nav-close:hover {
    background: rgba(212, 175, 55, 0.2);
    color: #D4AF37;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-nav-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s;
}

.mobile-nav-links a:hover,
.mobile-nav-links a.active {
    background: rgba(212, 175, 55, 0.1);
    color: #D4AF37;
}

.mobile-nav-links a i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}

.mobile-nav-cta {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-nav-overlay.active {
    display: block;
    opacity: 1;
}

/* ===================================
   Dashboard Mobile Toggle
   =================================== */
.dashboard-toggle-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #D4AF37, #B8941F);
    border: none;
    border-radius: 50%;
    color: #0A1628;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
    transition: all 0.3s;
}

.dashboard-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(212, 175, 55, 0.5);
}

@media (max-width: 768px) {
    .dashboard-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===================================
   Bottom Navigation (Alternative)
   =================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a2942;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + var(--safe-area-inset-bottom));
    z-index: 999;
}

@media (max-width: 576px) {
    .bottom-nav {
        display: block;
    }

    .bottom-nav-items {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: 0.5rem;
        color: #94a3b8;
        text-decoration: none;
        font-size: 0.7rem;
        transition: color 0.3s;
    }

    .bottom-nav-item i {
        font-size: 1.25rem;
    }

    .bottom-nav-item.active,
    .bottom-nav-item:hover {
        color: #D4AF37;
    }

    /* Add bottom padding to body when bottom nav is present */
    body.has-bottom-nav {
        padding-bottom: calc(60px + var(--safe-area-inset-bottom));
    }
}

/* ===================================
   Pull to Refresh Indicator
   =================================== */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: #1a2942;
    padding: 1rem 2rem;
    border-radius: 0 0 20px 20px;
    color: #D4AF37;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.3s;
    z-index: 9999;
}

.pull-to-refresh.active {
    transform: translateX(-50%) translateY(0);
}

.pull-to-refresh i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===================================
   Swipeable Components
   =================================== */
.swipeable-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.swipeable-container::-webkit-scrollbar {
    display: none;
}

.swipeable-item {
    scroll-snap-align: center;
    flex-shrink: 0;
}

/* ===================================
   Mobile Utility Classes
   =================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .show-mobile-flex {
        display: flex !important;
    }

    .text-center-mobile {
        text-align: center !important;
    }

    .full-width-mobile {
        width: 100% !important;
    }

    .stack-mobile {
        flex-direction: column !important;
    }

    .order-first-mobile {
        order: -1 !important;
    }

    .order-last-mobile {
        order: 999 !important;
    }

    .gap-sm-mobile {
        gap: 0.5rem !important;
    }

    .p-sm-mobile {
        padding: 0.75rem !important;
    }

    .m-0-mobile {
        margin: 0 !important;
    }
}

@media (min-width: 769px) {
    .show-mobile,
    .show-mobile-flex {
        display: none !important;
    }
}

/* ===================================
   Animated Hamburger Menu Icon
   =================================== */
.hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    cursor: pointer;
}

.hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    left: 0;
    transition: all 0.3s ease;
}

.hamburger span:nth-child(1) {
    top: 0;
}

.hamburger span:nth-child(2) {
    top: 8px;
}

.hamburger span:nth-child(3) {
    top: 16px;
}

.hamburger.active span:nth-child(1) {
    top: 8px;
    transform: rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    top: 8px;
    transform: rotate(-45deg);
}

/* ===================================
   Mobile Form Improvements
   =================================== */
@media (max-width: 576px) {
    /* Date/time inputs */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-height: 44px;
    }

    /* Select dropdowns */
    select.form-select {
        background-position: right 1rem center;
    }

    /* File inputs */
    .custom-file-upload {
        padding: 2rem 1rem;
        text-align: center;
    }

    .custom-file-upload i {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    /* Search inputs */
    .search-input-group {
        flex-direction: column;
    }

    .search-input-group input {
        border-radius: 8px !important;
    }

    .search-input-group button {
        border-radius: 8px !important;
        margin-top: 0.5rem;
    }
}

/* ===================================
   Performance Optimizations
   =================================== */
@media (max-width: 768px) {
    /* Reduce animations on mobile for performance */
    .reduce-motion-mobile * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Optimize canvas rendering */
    canvas {
        will-change: auto;
    }

    /* Lazy load non-critical images */
    img[loading="lazy"] {
        opacity: 0;
        transition: opacity 0.3s;
    }

    img[loading="lazy"].loaded {
        opacity: 1;
    }
}

/* ===================================
   Dark Mode Adjustments for Mobile
   =================================== */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .mobile-nav {
        background: linear-gradient(180deg, #0A1628 0%, #050b14 100%);
    }

    .bottom-nav {
        background: #0A1628;
    }
}
