/* ========================================
   RESPONSIVE DESIGN - Mobile First Approach
   Untuk semua halaman frontend dan admin
   ======================================== */

/* =====================================
   GENERAL MOBILE FIXES
   ===================================== */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Make images responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive containers */
.container {
    padding-left: 15px;
    padding-right: 15px;
}

/* =====================================
   FRONTEND RESPONSIVE
   ===================================== */

/* Hero Section Mobile */
@media (max-width: 767.98px) {
    .hero-section {
        min-height: 60vh !important;
        padding: 60px 0 40px !important;
    }
    
    .hero-content h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    .hero-content p {
        font-size: 0.95rem !important;
    }
    
    .hero-buttons .btn {
        font-size: 0.9rem !important;
        padding: 10px 20px !important;
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Search Form Mobile */
@media (max-width: 991.98px) {
    .search-form {
        padding: 20px 15px !important;
    }
    
    .search-form .form-select,
    .search-form .btn {
        margin-bottom: 10px;
        width: 100%;
    }
    
    /* Filter Section Mobile */
    .card.shadow-sm {
        margin-bottom: 20px;
    }
    
    .card-body h5 {
        font-size: 1rem;
    }
    
    .row.g-3 .col-md-3 {
        margin-bottom: 10px;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
}

@media (max-width: 767.98px) {
    .page-header {
        padding: 40px 0 !important;
    }
    
    .page-header h1 {
        font-size: 1.75rem !important;
        margin-bottom: 10px !important;
    }
    
    .page-header p {
        font-size: 0.9rem !important;
    }
    
    /* Filter buttons stack on mobile */
    .card-body .row .col-12 .btn {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .card-body .row .col-12 .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Results info */
    .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
    
    /* Section padding */
    .section {
        padding: 30px 0 !important;
    }
    
    .section.bg-light {
        padding: 30px 0 !important;
    }
    
    /* Container padding untuk mobile */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Card shadow and spacing */
    .card.shadow-sm {
        box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
        border-radius: 10px;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    .card-title {
        font-size: 1rem !important;
        margin-bottom: 15px !important;
    }
    
    /* Form elements spacing */
    .row.g-3 {
        gap: 0 !important;
    }
    
    .row.g-3 > [class*='col-'] {
        margin-bottom: 15px;
    }
    
    .row.g-3 > .col-12 {
        margin-bottom: 0;
        margin-top: 10px;
    }
    
    /* Empty state */
    .alert.alert-info {
        padding: 30px 20px;
        border-radius: 10px;
    }
    
    .alert.alert-info h5 {
        font-size: 1.1rem;
    }
    
    .alert.alert-info p {
        font-size: 0.9rem;
    }
    
    /* Cars grid spacing */
    .row.g-4 {
        gap: 1rem !important;
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }
    
    .row.g-4 > [class*='col-'] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* Small mobile devices */
@media (max-width: 576px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .section {
        padding: 20px 0 !important;
    }
    
    .row.g-4 {
        gap: 0.75rem !important;
        margin-left: -0.375rem !important;
        margin-right: -0.375rem !important;
    }
    
    .row.g-4 > [class*='col-'] {
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
        margin-bottom: 0 !important;
    }
    
    .page-header {
        padding: 30px 0 !important;
    }
    
    .page-header h1 {
        font-size: 1.5rem !important;
    }
    
    .page-header p {
        font-size: 0.85rem !important;
    }
}

/* Car Cards Mobile */
@media (max-width: 575.98px) {
    .car-card {
        margin-bottom: 20px;
    }
    
    .car-card img {
        height: 200px !important;
    }
    
    .car-specs {
        flex-wrap: wrap;
    }
    
    .car-spec {
        flex: 0 0 48%;
        margin-bottom: 8px;
        font-size: 0.85rem;
    }
    
    .car-price {
        font-size: 1.2rem !important;
    }
    
    /* Price Section Responsive */
    .car-price-section {
        padding: 10px;
    }
    
    .price-row {
        padding: 6px 8px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .price-label {
        font-size: 0.8rem;
    }
    
    .price-normal,
    .price-discount-small {
        font-size: 0.85rem;
    }
    
    .price-original-small {
        font-size: 0.7rem;
    }
}

/* Tablet responsive for car cards */
@media (min-width: 576px) and (max-width: 991.98px) {
    .car-price-section {
        padding: 10px;
    }
    
    .price-row {
        padding: 6px;
    }
    
    .price-label {
        font-size: 0.85rem;
    }
    
    .price-normal,
    .price-discount-small {
        font-size: 0.9rem;
    }
}

/* Stats Cards Mobile */
@media (max-width: 767.98px) {
    .stats-section {
        padding: 30px 0 !important;
    }
    
    .stat-card {
        margin-bottom: 15px;
        padding: 20px 15px !important;
    }
    
    .stat-card h3 {
        font-size: 2rem !important;
    }
    
    .stat-card p {
        font-size: 0.9rem !important;
    }
}

/* Gallery Mobile */
@media (max-width: 767.98px) {
    .gallery-item {
        margin-bottom: 15px;
    }
    
    .gallery-item img {
        height: 200px !important;
    }
}

/* Video Gallery Mobile */
@media (max-width: 767.98px) {
    .video-item {
        margin-bottom: 20px;
    }
    
    .video-item video,
    .video-item iframe {
        height: 200px !important;
    }
}

/* Footer Mobile */
@media (max-width: 767.98px) {
    .footer {
        text-align: center !important;
    }
    
    .footer-logo {
        margin-bottom: 20px;
    }
    
    .footer-col {
        margin-bottom: 30px;
    }
    
    .footer-col h5 {
        font-size: 1rem !important;
    }
}

/* =====================================
   CAR DETAILS PAGE MOBILE
   ===================================== */

@media (max-width: 991.98px) {
    .car-detail-image {
        height: 300px !important;
        margin-bottom: 20px;
    }
    
    .spec-card {
        margin-bottom: 15px;
    }
    
    .price-section {
        position: relative !important;
        margin-top: 20px;
    }
    
    .price-card {
        margin-bottom: 20px;
    }
}

@media (max-width: 575.98px) {
    .car-detail-image {
        height: 250px !important;
    }
    
    .page-header h1 {
        font-size: 1.5rem !important;
    }
}

/* =====================================
   ADMIN PANEL RESPONSIVE
   ===================================== */

/* Sidebar Mobile */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1050;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
    }
    
    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1049;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 8px;
        font-size: 1.2rem;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1049;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                    visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Smooth animation for sidebar menu items */
    .sidebar .menu-item {
        transition: all 0.3s ease;
    }
    
    .sidebar .menu-item:active {
        transform: scale(0.98);
    }
}

/* Admin Top Bar Mobile */
@media (max-width: 767.98px) {
    .top-bar,
    .top-navbar {
        padding: 15px !important;
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .top-bar h4,
    .top-navbar .page-title h5 {
        font-size: 1.1rem !important;
        margin-bottom: 10px;
    }
    
    .top-bar .btn,
    .top-navbar .btn {
        font-size: 0.85rem !important;
        padding: 8px 15px !important;
    }
    
    .admin-avatar {
        width: 35px !important;
        height: 35px !important;
        font-size: 0.9rem !important;
    }
}

/* Stats Cards Mobile (Admin Dashboard) */
@media (max-width: 767.98px) {
    .stats-card {
        margin-bottom: 15px;
        padding: 15px !important;
    }
    
    .stats-number {
        font-size: 1.8rem !important;
    }
    
    .stats-label {
        font-size: 0.85rem !important;
    }
    
    .stats-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.2rem !important;
    }
}

/* Tables Mobile */
@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 800px;
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 8px !important;
        white-space: nowrap;
    }
    
    /* Mobile table scroll hint */
    .table-responsive::after {
        content: "← Scroll untuk melihat lebih banyak →";
        display: block;
        text-align: center;
        padding: 10px;
        color: #6c757d;
        font-size: 0.85rem;
        font-style: italic;
    }
}

/* Filter Tabs Mobile */
@media (max-width: 767.98px) {
    .filter-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .filter-tab {
        flex: 0 0 calc(50% - 4px);
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        text-align: center;
        margin: 0 !important;
    }
    
    .filter-tab i {
        display: block;
        margin-bottom: 3px;
    }
}

/* Forms Mobile */
@media (max-width: 767.98px) {
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-label {
        font-size: 0.9rem !important;
        margin-bottom: 5px;
    }
    
    .form-control,
    .form-select {
        font-size: 0.9rem !important;
        padding: 10px !important;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Balance Card Mobile */
@media (max-width: 767.98px) {
    .balance-card {
        padding: 20px 15px !important;
    }
    
    .balance-label {
        font-size: 0.9rem !important;
    }
    
    .balance-amount {
        font-size: 1.8rem !important;
    }
    
    .balance-card .row {
        text-align: center;
    }
    
    .balance-card .col-md-4 {
        margin-top: 15px;
    }
}

/* Content Cards Mobile */
@media (max-width: 767.98px) {
    .content-card {
        padding: 15px !important;
        margin-bottom: 15px;
    }
    
    .content-card h5 {
        font-size: 1rem !important;
        margin-bottom: 15px !important;
    }
}

/* Action Buttons Mobile */
@media (max-width: 575.98px) {
    .action-buttons {
        display: flex;
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .btn-sm {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
}

/* Modal Mobile */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-content {
        border-radius: 10px;
    }
    
    .modal-header {
        padding: 15px !important;
    }
    
    .modal-body {
        padding: 15px !important;
    }
    
    .modal-title {
        font-size: 1.1rem !important;
    }
}

/* =====================================
   DOCUMENT PAGES MOBILE (Invoice, Contract, etc)
   ===================================== */

@media (max-width: 991.98px) {
    .document-container {
        padding: 15px !important;
    }
    
    .document-header {
        flex-direction: column;
        text-align: center;
    }
    
    .document-header img {
        max-width: 120px !important;
        margin-bottom: 15px;
    }
    
    .document-title h2 {
        font-size: 1.3rem !important;
    }
    
    .document-info table {
        font-size: 0.85rem !important;
    }
    
    .signature-section {
        flex-direction: column;
    }
    
    .signature-box {
        width: 100% !important;
        margin-bottom: 20px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .top-bar,
    .top-navbar,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .document-container {
        padding: 0 !important;
        box-shadow: none !important;
    }
}

/* =====================================
   GALLERY & VIDEO PAGES MOBILE
   ===================================== */

@media (max-width: 767.98px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .video-grid {
        grid-template-columns: 1fr !important;
    }
    
    .gallery-card,
    .video-card {
        margin-bottom: 15px;
    }
    
    .gallery-image,
    .video-thumbnail {
        height: 150px !important;
    }
}

/* =====================================
   SETTINGS PAGE MOBILE
   ===================================== */

@media (max-width: 767.98px) {
    .settings-tabs {
        flex-direction: column;
    }
    
    .settings-tab {
        width: 100%;
        text-align: left;
        margin-bottom: 5px;
    }
    
    .settings-content {
        padding: 15px !important;
    }
}

/* =====================================
   RENTAL REPORT MOBILE
   ===================================== */

@media (max-width: 767.98px) {
    .date-filter {
        flex-direction: column;
    }
    
    .date-filter .form-group {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr !important;
    }
    
    .chart-container {
        overflow-x: auto;
    }
}

/* =====================================
   UTILITY CLASSES
   ===================================== */

/* Hide on mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 767.98px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none;
}

@media (max-width: 767.98px) {
    .show-mobile {
        display: block !important;
    }
}

/* Text responsive */
@media (max-width: 767.98px) {
    .text-sm-center {
        text-align: center !important;
    }
    
    .text-sm-left {
        text-align: left !important;
    }
}

/* Spacing mobile */
@media (max-width: 767.98px) {
    .mb-sm-3 {
        margin-bottom: 1rem !important;
    }
    
    .mt-sm-3 {
        margin-top: 1rem !important;
    }
    
    .p-sm-2 {
        padding: 0.5rem !important;
    }
}

/* =====================================
   FIX COMMON ISSUES
   ===================================== */

/* Fix Bootstrap overflow */
.row {
    margin-left: -10px;
    margin-right: -10px;
}

.col, [class*="col-"] {
    padding-left: 10px;
    padding-right: 10px;
}

/* Fix button wrapping */
.btn {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .btn {
        white-space: normal;
    }
}

/* Fix long text overflow */
.text-truncate-mobile {
    white-space: normal;
}

@media (max-width: 767.98px) {
    .text-truncate-mobile {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Improve touch targets */
@media (max-width: 767.98px) {
    .btn,
    .form-control,
    .form-select,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* =====================================
   ADMIN EDIT PAGES RESPONSIVE
   ===================================== */

/* Form Cards Responsive */
@media (max-width: 991.98px) {
    .form-card {
        padding: 20px 15px !important;
        margin: 10px 0 !important;
    }
    
    .form-section h6 {
        font-size: 1rem !important;
    }
}

/* Form Controls Mobile */
@media (max-width: 767.98px) {
    /* Full width inputs on mobile */
    .form-control,
    .form-select,
    .input-group {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Stack form rows */
    .row.mb-3 > [class*="col-"] {
        margin-bottom: 15px !important;
    }
    
    .row.mb-3 > [class*="col-"]:last-child {
        margin-bottom: 0 !important;
    }
    
    /* Make all form columns full width on mobile */
    .form-card .row > .col-md-3,
    .form-card .row > .col-md-4,
    .form-card .row > .col-md-6,
    .form-card .row > .col-md-8,
    .form-card .row > .col-md-9 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    /* Buttons mobile */
    .form-card .btn {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    .form-card .text-end {
        text-align: left !important;
    }
    
    /* Input groups */
    .input-group-text {
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
    
    /* Labels */
    .form-label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
    }
    
    /* Small text */
    .form-card small {
        font-size: 12px !important;
    }
}

/* Edit Page Specific */
@media (max-width: 767.98px) {
    /* Rental Edit specific */
    .rental-info-card,
    .payment-card,
    .operational-card {
        margin-bottom: 15px !important;
        padding: 15px !important;
    }
    
    /* Car images in forms */
    .car-image-small {
        width: 50px !important;
        height: 50px !important;
    }
    
    /* Stats/Info boxes */
    .info-box,
    .stats-card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    /* Tables in edit forms */
    .table-responsive-wrapper {
        margin: 0 -15px !important;
    }
    
    .form-card .table {
        font-size: 12px !important;
    }
    
    .form-card .table td,
    .form-card .table th {
        padding: 8px 5px !important;
    }
}

/* Edit Buttons Bar */
@media (max-width: 767.98px) {
    .edit-actions,
    .form-actions,
    .button-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .edit-actions .btn,
    .form-actions .btn,
    .button-group .btn {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* Tabs responsive */
@media (max-width: 767.98px) {
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap !important;
        font-size: 14px !important;
        padding: 10px 15px !important;
    }
}

/* Image upload preview */
@media (max-width: 767.98px) {
    .image-preview,
    .video-preview {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Readonly/Disabled inputs on mobile */
@media (max-width: 767.98px) {
    input[readonly],
    input[disabled],
    select[disabled],
    textarea[readonly] {
        background-color: #f5f5f5 !important;
        opacity: 0.8 !important;
    }
}

