/* =====================================================
   MOBILE.CSS - OPTIMASI KHUSUS UNTUK HANDPHONE
   Versi 2.0 - Complete Mobile Optimization
   ===================================================== */

/* Base mobile styles */
@media (max-width: 768px) {
    /* Reset untuk mobile */
    body {
        overflow-x: hidden;
        width: 100%;
        font-size: 14px;
        background: #f4f7fc;
        padding-bottom: 0;
        margin: 0;
    }
    
    /* Container utama */
    .container-fluid {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Row dan col untuk mobile */
    .row {
        margin: 0 !important;
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
    }
    
    [class*="col-"] {
        padding: 8px !important;
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Khusus untuk kolom dengan ukuran tertentu di mobile */
    .col-6, .col-sm-6, .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 5px !important;
    }
    
    .col-4, .col-sm-4, .col-md-4 {
        flex: 0 0 33.333% !important;
        max-width: 33.333% !important;
        padding: 5px !important;
    }
    
    .col-3, .col-sm-3, .col-md-3 {
        flex: 0 0 25% !important;
        max-width: 25% !important;
        padding: 5px !important;
    }
    
    /* =====================================================
       BOTTOM NAVIGATION - SIDEBAR
       ===================================================== */
    
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        height: 70px !important;
        min-height: auto !important;
        z-index: 9999 !important;
        display: flex !important;
        flex-direction: row !important;
        padding: 5px 0 !important;
        background: linear-gradient(135deg, #1e3c72 0%, #2a4f8c 50%, #3a6ab5 100%) !important;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.2) !important;
        width: 100% !important;
        border-top: 1px solid rgba(255,255,255,0.2) !important;
    }
    
    /* Sembunyikan elemen yang tidak perlu di sidebar mobile */
    .sidebar .text-center {
        display: none !important;
    }
    
    .sidebar hr {
        display: none !important;
    }
    
    /* Style link di bottom nav */
    .sidebar a {
        flex: 1 !important;
        padding: 8px 2px !important;
        text-align: center !important;
        font-size: 11px !important;
        color: rgba(255, 255, 255, 0.9) !important;
        text-decoration: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        border-left: none !important;
        background: transparent !important;
        transition: all 0.2s ease !important;
        border-radius: 0 !important;
        font-weight: 500 !important;
    }
    
    .sidebar a i {
        font-size: 22px !important;
        margin: 0 0 3px 0 !important;
        display: block !important;
        color: rgba(255, 255, 255, 0.9) !important;
    }
    
    .sidebar a:hover {
        background: rgba(255, 255, 255, 0.15) !important;
        color: white !important;
    }
    
    .sidebar a:hover i {
        color: white !important;
    }
    
    .sidebar a.active {
        background: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        border-left: none !important;
        border-top: 3px solid white !important;
        font-weight: 600 !important;
    }
    
    .sidebar a.active i {
        color: white !important;
    }
    
    /* Sembunyikan teks menu di bottom nav untuk hemat space (opsional) */
    .sidebar a .menu-text {
        display: block !important; /* Tampilkan teks */
        font-size: 10px !important;
    }
    
    /* Main content dengan padding bottom untuk bottom nav */
    .main-content {
        margin-left: 0 !important;
        padding: 15px 12px 85px 12px !important;
        width: 100% !important;
        min-height: calc(100vh - 70px) !important;
    }
    
    /* =====================================================
       HEADER & TITLE
       ===================================================== */
    
    h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word !important;
    }
    
    h2 {
        font-size: 22px !important;
        margin-bottom: 15px !important;
    }
    
    /* =====================================================
       STATISTIC CARDS - RESPONSIVE
       ===================================================== */
    
    .stat-card {
        padding: 15px !important;
        margin-bottom: 10px !important;
        width: 100% !important;
        border-radius: 16px !important;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        background: white !important;
        box-shadow: 0 3px 15px rgba(0,0,0,0.05) !important;
        border: 1px solid rgba(0,0,0,0.03) !important;
    }
    
    .stat-card .stat-number {
        font-size: 20px !important;
        font-weight: 700 !important;
    }
    
    .stat-card .stat-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 22px !important;
        flex-shrink: 0 !important;
        border-radius: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .stat-card h6 {
        font-size: 12px !important;
        margin-bottom: 2px !important;
    }
    
    /* =====================================================
       CARDS
       ===================================================== */
    
    .card {
        width: 100% !important;
        margin-bottom: 15px !important;
        border-radius: 18px !important;
        border: none !important;
        box-shadow: 0 5px 20px rgba(0,0,0,0.05) !important;
        overflow: hidden !important;
    }
    
    .card-header {
        padding: 15px 15px !important;
        background: white !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
    
    .card-header h5 {
        font-size: 16px !important;
        margin: 0 !important;
        font-weight: 600 !important;
    }
    
    .card-header h5 i {
        font-size: 18px !important;
    }
    
    .card-body {
        padding: 15px !important;
        overflow-x: auto !important;
    }
    
    /* =====================================================
       TOMBOL - MOBILE OPTIMIZED
       ===================================================== */
    
    button, .btn {
        width: 100% !important;
        margin: 5px 0 !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        border-radius: 14px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        font-weight: 600 !important;
        border: none !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
    }
    
    .btn i {
        font-size: 18px !important;
    }
    
    .btn-group {
        display: flex !important;
        width: 100% !important;
        gap: 8px !important;
        margin: 10px 0 !important;
    }
    
    .btn-group .btn {
        width: 50% !important;
        margin: 0 !important;
        flex: 1 !important;
    }
    
    /* Tombol absensi khusus */
    .btn-absensi {
        padding: 18px 16px !important;
        font-size: 17px !important;
        margin: 10px 0 20px 0 !important;
        border-radius: 16px !important;
        background: linear-gradient(135deg, #1e3c72 0%, #2a4f8c 100%) !important;
        color: white !important;
        box-shadow: 0 8px 20px rgba(42,79,140,0.3) !important;
    }
    
    .btn-absensi i {
        font-size: 22px !important;
    }
    
    /* Tombol primary */
    .btn-primary {
        background: linear-gradient(135deg, #1e3c72 0%, #2a4f8c 100%) !important;
        color: white !important;
    }
    
    .btn-success {
        background: linear-gradient(135deg, #0b5e2e 0%, #15803d 100%) !important;
        color: white !important;
    }
    
    .btn-danger {
        background: linear-gradient(135deg, #991b1b 0%, #b91c1c 100%) !important;
        color: white !important;
    }
    
    .btn-warning {
        background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%) !important;
        color: white !important;
    }
    
    /* =====================================================
       FORM ELEMENTS
       ===================================================== */
    
    input, select, textarea {
        width: 100% !important;
        font-size: 16px !important; /* Mencegah zoom di iOS */
        padding: 15px 16px !important;
        margin: 5px 0 12px 0 !important;
        border-radius: 14px !important;
        border: 2px solid #e5e7eb !important;
        background: white !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }
    
    input:focus, select:focus, textarea:focus {
        border-color: #2a4f8c !important;
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(42,79,140,0.1) !important;
    }
    
    label {
        font-size: 14px !important;
        margin-bottom: 5px !important;
        display: block !important;
        font-weight: 600 !important;
        color: #374151 !important;
    }
    
    /* Select dropdown dengan icon panah */
    select {
        background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 15px center !important;
        padding-right: 45px !important;
    }
    
    /* =====================================================
       TABLES - HORIZONTAL SCROLL
       ===================================================== */
    
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -5px !important;
        padding: 0 5px !important;
        width: 100% !important;
        border-radius: 12px !important;
    }
    
    table {
        min-width: 600px !important;
        font-size: 13px !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        width: 100% !important;
    }
    
    td, th {
        padding: 12px 10px !important;
        white-space: nowrap !important;
        text-align: left !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
    
    th {
        background: #f9fafb !important;
        font-weight: 600 !important;
        color: #374151 !important;
        font-size: 12px !important;
    }
    
    /* =====================================================
       LOCATION TAGS
       ===================================================== */
    
    .location-tag {
        display: inline-block !important;
        padding: 8px 14px !important;
        margin: 4px !important;
        font-size: 13px !important;
        border-radius: 30px !important;
        width: auto !important;
        background: #e6f0ff !important;
        color: #1e3c72 !important;
        border: 1px solid #2a4f8c !important;
        font-weight: 500 !important;
    }
    
    .location-tag .badge {
        margin-left: 6px !important;
        font-size: 10px !important;
    }
    
    /* =====================================================
       BADGES
       ===================================================== */
    
    .badge {
        font-size: 11px !important;
        padding: 5px 10px !important;
        border-radius: 30px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        font-weight: 600 !important;
    }
    
    /* =====================================================
       STATUS BOX
       ===================================================== */
    
    .status-box {
        padding: 14px !important;
        font-size: 14px !important;
        margin: 12px 0 !important;
        border-radius: 14px !important;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        border-left: 5px solid !important;
    }
    
    .status-box i {
        font-size: 22px !important;
    }
    
    .status-success {
        background: #e6ffe6 !important;
        color: #0b5e2e !important;
        border-left-color: #15803d !important;
    }
    
    .status-warning {
        background: #fff3cd !important;
        color: #856404 !important;
        border-left-color: #ffc107 !important;
    }
    
    .status-danger {
        background: #ffe6e6 !important;
        color: #991b1b !important;
        border-left-color: #b91c1c !important;
    }
    
    /* =====================================================
       CAMERA BOX
       ===================================================== */
    
    .camera-box {
        padding: 15px !important;
        width: 100% !important;
        background: white !important;
        border-radius: 20px !important;
        box-shadow: 0 5px 20px rgba(0,0,0,0.1) !important;
        margin-bottom: 20px !important;
    }
    
    video, canvas {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        border-radius: 16px !important;
        background: #1f2937 !important;
    }
    
    /* =====================================================
       MODAL
       ===================================================== */
    
    .modal-dialog {
        margin: 15px !important;
        max-width: calc(100% - 30px) !important;
    }
    
    .modal-content {
        border-radius: 24px !important;
        padding: 0 !important;
        border: none !important;
        overflow: hidden !important;
    }
    
    .modal-header {
        padding: 18px 18px 12px 18px !important;
        background: linear-gradient(135deg, #1e3c72 0%, #2a4f8c 100%) !important;
        color: white !important;
        border: none !important;
    }
    
    .modal-header .modal-title {
        font-size: 18px !important;
        font-weight: 700 !important;
    }
    
    .modal-header .btn-close {
        filter: brightness(0) invert(1) !important;
        opacity: 0.8 !important;
    }
    
    .modal-body {
        padding: 20px !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
    }
    
    .modal-footer {
        padding: 15px 20px !important;
        border-top: 1px solid #e5e7eb !important;
        display: flex !important;
        gap: 10px !important;
    }
    
    .modal-footer .btn {
        margin: 0 !important;
        flex: 1 !important;
    }
    
    /* =====================================================
       ALERTS
       ===================================================== */
    
    .alert {
        padding: 14px 16px !important;
        font-size: 14px !important;
        margin: 12px 0 !important;
        border-radius: 14px !important;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        border: none !important;
    }
    
    .alert i {
        font-size: 20px !important;
    }
    
    /* =====================================================
       LOGIN & WELCOME CARD
       ===================================================== */
    
    .login-card, .welcome-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 25px 20px !important;
        margin: 15px !important;
        border-radius: 28px !important;
    }
    
    .login-header h2 {
        font-size: 26px !important;
    }
    
    .features {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin: 20px 0 !important;
    }
    
    .feature-item {
        padding: 15px 8px !important;
        text-align: center !important;
        background: #f9fafb !important;
        border-radius: 16px !important;
    }
    
    .feature-item i {
        font-size: 28px !important;
        margin-bottom: 8px !important;
    }
    
    .feature-item h6 {
        font-size: 13px !important;
        font-weight: 600 !important;
    }
    
    .feature-item p {
        font-size: 11px !important;
        color: #6b7280 !important;
    }
    
    /* Demo accounts */
    .demo-accounts {
        padding: 16px !important;
        margin-top: 20px !important;
    }
    
    .demo-item {
        flex-wrap: wrap !important;
        gap: 8px !important;
        font-size: 13px !important;
    }
    
    .demo-item code {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
    
    /* Back link */
    .back-link {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
        padding: 14px !important;
        margin-top: 15px !important;
        border-radius: 50px !important;
        background: #f3f4f6 !important;
    }
    
    /* =====================================================
       PROGRESS & SPINNER
       ===================================================== */
    
    .progress {
        height: 8px !important;
        margin: 15px 0 !important;
        border-radius: 30px !important;
    }
    
    .spinner {
        width: 35px !important;
        height: 35px !important;
        border-width: 4px !important;
    }
    
    /* =====================================================
       HIDE DESKTOP ELEMENTS
       ===================================================== */
    
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    /* =====================================================
       FIX FOR SAFARI & IOS
       ===================================================== */
    
    input[type="date"] {
        min-height: 50px !important;
    }
    
    /* Fix untuk tombol di iOS */
    @supports (-webkit-touch-callout: none) {
        .btn, button {
            -webkit-appearance: none !important;
        }
        
        input, select, textarea {
            font-size: 16px !important;
        }
    }
}

/* =====================================================
   UNTUK LAYAR SANGAT KECIL (< 375px)
   ===================================================== */

@media (max-width: 375px) {
    .sidebar a {
        font-size: 9px !important;
        padding: 6px 2px !important;
    }
    
    .sidebar a i {
        font-size: 20px !important;
    }
    
    .sidebar a .menu-text {
        font-size: 9px !important;
    }
    
    .stat-card .stat-number {
        font-size: 18px !important;
    }
    
    .stat-card .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }
    
    .btn-group {
        flex-direction: column !important;
        gap: 5px !important;
    }
    
    .btn-group .btn {
        width: 100% !important;
        margin: 2px 0 !important;
    }
    
    .features {
        grid-template-columns: 1fr !important;
    }
    
    h2 {
        font-size: 20px !important;
    }
    
    .location-tag {
        width: 100% !important;
        text-align: center !important;
    }
}

/* =====================================================
   LANDSCAPE MODE
   ===================================================== */

@media (max-width: 900px) and (orientation: landscape) {
    .sidebar {
        height: 60px !important;
    }
    
    .sidebar a i {
        font-size: 20px !important;
        margin-bottom: 2px !important;
    }
    
    .sidebar a {
        font-size: 10px !important;
        padding: 5px 2px !important;
    }
    
    .main-content {
        padding-bottom: 75px !important;
    }
    
    .camera-box video {
        max-height: 180px !important;
        width: auto !important;
        margin: 0 auto !important;
    }
    
    .modal-dialog {
        max-width: 80% !important;
        margin: 30px auto !important;
    }
    
    .stat-card {
        padding: 12px !important;
    }
    
    .stat-card .stat-icon {
        width: 35px !important;
        height: 35px !important;
        font-size: 18px !important;
    }
}

/* =====================================================
   TABLET (768px - 1024px)
   ===================================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    [class*="col-"] {
        padding: 12px !important;
    }
    
    .col-md-3 {
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }
    
    .col-md-4 {
        flex: 0 0 33.333% !important;
        max-width: 33.333% !important;
    }
    
    .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    .sidebar {
        width: 220px !important;
    }
    
    .sidebar a {
        padding: 12px 15px !important;
        font-size: 13px !important;
    }
    
    .sidebar a i {
        font-size: 18px !important;
        margin-right: 10px !important;
    }
    
    .main-content {
        margin-left: 220px !important;
        width: calc(100% - 220px) !important;
        padding: 25px !important;
    }
    
    .stat-card {
        padding: 18px !important;
    }
    
    .stat-card .stat-number {
        font-size: 24px !important;
    }
    
    .stat-card .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
    }
}

/* =====================================================
   UTILITY & OVERFLOW
   ===================================================== */

* {
    max-width: 100%;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Hilangkan highlight tap di mobile */
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Custom scrollbar untuk mobile (lebih tipis) */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Fix untuk input date di mobile */
input[type="date"]::-webkit-calendar-picker-indicator {
    padding: 5px;
    opacity: 0.6;
}

/* Fix untuk select dropdown */
select {
    word-wrap: normal;
    text-overflow: ellipsis;
}