/* ============================================
   DOCUMENTS MOBILE-FIRST RESPONSIVE CSS
   Layout 2 Kolom seperti Shopee
   ============================================ */

:root {
    --card-spacing: 0.5rem;
    --card-padding: 0.75rem;
    --text-sm: 0.75rem;
    --text-xs: 0.7rem;
    --radius: 8px;
}

/* ============================================
   GLOBAL COMPACT STYLES
   ============================================ */
.documents-list-container,
.documents-form-container,
.admin-dashboard {
    padding: 0.5rem !important;
}

.page-title {
    font-size: 1.1rem !important;
    margin-bottom: 0.25rem !important;
}

.page-subtitle {
    font-size: var(--text-sm) !important;
    margin-bottom: 0.5rem !important;
}

/* ============================================
   MOBILE STATISTICS CARDS - 2 COLUMN GRID
   ============================================ */
@media (max-width: 768px) {
    /* Dashboard Stats - 2 Kolom */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    .stat-cart {
        padding: 0.75rem !important;
        border-radius: var(--radius) !important;
    }
    
    .stat-icon {
        width: 35px !important;
        height: 35px !important;
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .stat-number {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .stat-label {
        font-size: var(--text-sm) !important;
        margin-bottom: 0.25rem !important;
    }
    
    .stat-description {
        font-size: var(--text-xs) !important;
        display: none !important; /* Hide on mobile for compact */
    }
    
    /* Category Stats - 2 Kolom */
    .row.mb-4 {
        margin-bottom: 0.5rem !important;
    }
    
    .col-md-3 {
        padding: 0.25rem !important;
    }
    
    .category-card {
        margin-bottom: 0 !important;
    }
    
    .category-card .card-body {
        padding: 0.75rem !important;
    }
    
    .category-card h3 {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .category-card p {
        font-size: var(--text-xs) !important;
        margin-bottom: 0 !important;
    }
    
    .category-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Categories Grid - 2 Kolom */
    .row > [class*="col-"] {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }
    
    .col-md-6.col-lg-4 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    .category-card.h-100 .card-body {
        padding: 0.75rem !important;
    }
    
    .category-card h5 {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .category-card .card-text {
        font-size: var(--text-xs) !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    
    .badge-count {
        font-size: var(--text-xs) !important;
        padding: 2px 6px !important;
        border-radius: 6px !important;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.7rem !important;
    }
}

/* ============================================
   MOBILE HEADER
   ============================================ */
@media (max-width: 768px) {
    .documents-list-header,
    .dashboard-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .header-left,
    .header-right {
        width: 100% !important;
    }
    
    .header-right {
        display: flex !important;
        gap: 0.5rem !important;
    }
    
    .header-right .btn {
        flex: 1 !important;
        font-size: var(--text-sm) !important;
        padding: 0.5rem !important;
    }
    
    .header-meta {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        font-size: var(--text-xs) !important;
    }
}

/* ============================================
   MOBILE FILTER SECTION - COMPACT
   ============================================ */
@media (max-width: 768px) {
    .card.mb-3 .card-body {
        padding: 0.75rem !important;
    }
    
    .row.g-2 {
        --bs-gutter-x: 0.5rem !important;
        --bs-gutter-y: 0.5rem !important;
    }
    
    .form-control-sm,
    .form-select-sm {
        font-size: var(--text-sm) !important;
        padding: 0.4rem 0.6rem !important;
        height: auto !important;
    }
    
    .btn-sm {
        font-size: var(--text-sm) !important;
        padding: 0.4rem 0.6rem !important;
    }
    
    .btn-group.w-100 .btn {
        flex: 1 !important;
    }
}

/* ============================================
   MOBILE TABLE - HORIZONTAL SCROLL
   ============================================ */
@media (max-width: 768px) {
    .table-responsive {
        margin: -0.75rem !important;
        padding: 0.75rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .table {
        font-size: var(--text-xs) !important;
        margin-bottom: 0.5rem !important;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.4rem !important;
        white-space: nowrap !important;
    }
    
    .table th {
        font-size: var(--text-xs) !important;
        font-weight: 600 !important;
    }
    
    .badge {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
    }
    
    .btn-group-sm {
        flex-wrap: nowrap !important;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.7rem !important;
    }
}

/* ============================================
   MOBILE FORM - COMPACT & STACKED
   ============================================ */
@media (max-width: 768px) {
    .documents-form-card,
    .card {
        border-radius: var(--radius) !important;
        margin-bottom: 0.5rem !important;
    }
    
    .card-header {
        padding: 0.75rem !important;
    }
    
    .card-header h5 {
        font-size: 1rem !important;
        margin-bottom: 0 !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    .form-label {
        font-size: var(--text-sm) !important;
        margin-bottom: 0.25rem !important;
        font-weight: 600 !important;
    }
    
    .form-control,
    .form-select {
        font-size: var(--text-sm) !important;
        padding: 0.5rem !important;
        border-radius: var(--radius) !important;
    }
    
    .form-text {
        font-size: var(--text-xs) !important;
        margin-top: 0.25rem !important;
    }
    
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .row > .col-md-6,
    .row > .col-md-12 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    h6.border-bottom {
        font-size: 0.875rem !important;
        padding-bottom: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Form Action Buttons - 2 Column Grid */
    .d-flex.gap-2 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    .d-flex.gap-2 .btn {
        font-size: var(--text-sm) !important;
        padding: 0.6rem !important;
    }
    
    .d-flex.gap-2 .ms-auto {
        margin-left: 0 !important;
        grid-column: span 2 !important;
    }
}

/* ============================================
   MOBILE DETAIL PAGE - COMPACT INFO
   ============================================ */
@media (max-width: 768px) {
    .document-detail-card {
        margin-bottom: 0.75rem !important;
    }
    
    .document-header {
        padding: 1rem !important;
    }
    
    .document-header h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .document-meta {
        gap: 0.5rem !important;
        font-size: var(--text-xs) !important;
    }
    
    .meta-item {
        gap: 0.25rem !important;
    }
    
    .info-row {
        padding: 0.75rem 0 !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
    }
    
    .info-label {
        font-size: var(--text-sm) !important;
        font-weight: 600 !important;
        min-width: auto !important;
    }
    
    .info-value {
        font-size: var(--text-sm) !important;
    }
    
    .comment-card {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .comment-card strong {
        font-size: var(--text-sm) !important;
    }
    
    .comment-card small {
        font-size: var(--text-xs) !important;
    }
    
    .comment-card p {
        font-size: var(--text-sm) !important;
    }
}

/* ============================================
   MOBILE PDF PREVIEW - COMPACT CONTROLS
   ============================================ */
@media (max-width: 768px) {
    .pdf-header {
        padding: 0.75rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .pdf-header h4 {
        font-size: 1rem !important;
    }
    
    .pdf-header p {
        font-size: var(--text-xs) !important;
    }
    
    .pdf-controls {
        padding: 0.5rem !important;
        gap: 0.5rem !important;
        flex-wrap: wrap !important;
    }
    
    .nav-controls,
    .zoom-controls {
        gap: 0.25rem !important;
    }
    
    .nav-controls button,
    .zoom-controls button {
        min-width: 32px !important;
        height: 32px !important;
        font-size: 0.75rem !important;
        padding: 0 !important;
    }
    
    .page-info {
        font-size: var(--text-xs) !important;
        padding: 0.3rem 0.6rem !important;
    }
    
    #page-num-input {
        width: 40px !important;
        font-size: var(--text-xs) !important;
    }
    
    .pdf-viewer-wrapper {
        padding: 0.5rem !important;
        min-height: 300px !important;
    }
    
    #pdf-canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ============================================
   MOBILE PAGINATION - COMPACT
   ============================================ */
@media (max-width: 768px) {
    .pagination {
        font-size: var(--text-xs) !important;
        margin-bottom: 0.5rem !important;
    }
    
    .page-link {
        padding: 0.4rem 0.6rem !important;
        font-size: var(--text-xs) !important;
    }
    
    .text-center.text-muted small {
        font-size: var(--text-xs) !important;
    }
}

/* ============================================
   MOBILE MODAL - FULL WIDTH
   ============================================ */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-header {
        padding: 0.75rem !important;
    }
    
    .modal-title {
        font-size: 1rem !important;
    }
    
    .modal-body {
        padding: 0.75rem !important;
    }
    
    .modal-footer {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
    }
    
    .modal-footer .btn {
        font-size: var(--text-sm) !important;
        padding: 0.5rem !important;
    }
}

/* ============================================
   MOBILE EMPTY STATE
   ============================================ */
@media (max-width: 768px) {
    .empty-state {
        padding: 2rem 1rem !important;
    }
    
    .empty-state i {
        font-size: 2rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .empty-state p {
        font-size: var(--text-sm) !important;
        margin-bottom: 0.75rem !important;
    }
    
    .text-center.py-5 {
        padding: 2rem 1rem !important;
    }
    
    .text-center.py-5 i {
        font-size: 2rem !important;
    }
    
    .text-center.py-5 p {
        font-size: var(--text-sm) !important;
    }
}

/* ============================================
   MOBILE BACK BUTTON
   ============================================ */
@media (max-width: 768px) {
    .mb-3 > .btn-sm {
        font-size: var(--text-sm) !important;
        padding: 0.5rem 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* ============================================
   MOBILE RECENT DOCUMENTS TABLE
   ============================================ */
@media (max-width: 768px) {
    .stats-cart-container {
        margin-bottom: 0.75rem !important;
    }
    
    .cart-header {
        padding: 0.75rem !important;
    }
    
    .cart-title {
        font-size: 1rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .cart-subtitle {
        font-size: var(--text-xs) !important;
        margin-bottom: 0 !important;
    }
    
    .system-info-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    .system-info-cart {
        padding: 0.5rem !important;
    }
    
    .info-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.875rem !important;
    }
    
    .info-label {
        font-size: var(--text-xs) !important;
    }
    
    .info-value {
        font-size: 1rem !important;
    }
}

/* ============================================
   ULTRA COMPACT MODE (< 375px)
   ============================================ */
@media (max-width: 375px) {
    :root {
        --card-padding: 0.5rem;
        --text-sm: 0.7rem;
        --text-xs: 0.65rem;
    }
    
    .page-title {
        font-size: 1rem !important;
    }
    
    .stat-number {
        font-size: 1.1rem !important;
    }
    
    .stat-icon {
        width: 30px !important;
        height: 30px !important;
    }
    
    .btn {
        font-size: 0.7rem !important;
        padding: 0.4rem 0.5rem !important;
    }
}

/* ============================================
   DESKTOP OPTIMIZATION (> 768px)
   ============================================ */
@media (min-width: 769px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .system-info-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .category-card {
        transition: transform 0.2s ease !important;
    }
    
    .category-card:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
}

