﻿/* Move down content because we have a fixed navbar that is 50px tall */
body {
    padding-top: 50px;
    padding-bottom: 20px;
}

/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
    padding-left: 15px;
    padding-right: 15px;
}

/* Set widths on the form inputs since otherwise they're 100% wide */
input,
select,
textarea {
    max-width: 1024px;
}


/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
    .jumbotron {
        margin-top: 20px;
    }

    .body-content {
        padding: 0;
    }
}

/* ============================================================
   MOBILE-FIRST TABLE RESPONSIVE STANDARDS
   ============================================================
   Use these classes for ALL tables/GridViews in the system
   to ensure proper mobile scrolling
   ============================================================ */

/* Standard Mobile Table Container */
.mobile-table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
    display: block;
    max-width: 100%;
    margin-bottom: 15px;
}

/* Visible scrollbar on mobile */
.mobile-table-wrapper::-webkit-scrollbar {
    height: 8px;
    display: block;
}

.mobile-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.mobile-table-wrapper::-webkit-scrollbar-thumb {
    background: #5D4037;
    border-radius: 4px;
    min-width: 40px;
}

.mobile-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #3E2723;
}

/* Tables inside wrapper must have min-width for scroll */
.mobile-table-wrapper table,
.mobile-table-wrapper .gridview-table,
.mobile-table-wrapper > [id*="GridView"],
.mobile-table-wrapper > table {
    min-width: 600px;
    width: 100%;
}

/* Mobile-specific adjustments */
@media (max-width: 992px) {
    .mobile-table-wrapper {
        margin-left: -15px;
        margin-right: -15px;
        padding: 0 15px;
        width: calc(100% + 30px);
    }
}

@media (max-width: 768px) {
    /* Force scrolling on small screens */
    .mobile-table-wrapper {
        overflow-x: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y !important;
    }

    /* Show scroll hint before table on mobile */
    .mobile-table-wrapper::before {
        content: '👆 เลื่อนซ้าย-ขวาเพื่อดูข้อมูลเพิ่มเติม';
        display: block;
        text-align: center;
        padding: 8px 12px;
        font-size: 12px;
        font-weight: 500;
        color: #fff;
        background: linear-gradient(135deg, #5D4037, #8D6E63);
        border-radius: 6px 6px 0 0;
        position: sticky;
        left: 0;
        right: 0;
        z-index: 5;
    }

    /* Ensure tables have minimum width for proper scrolling */
    .mobile-table-wrapper table,
    .mobile-table-wrapper .gridview-table,
    .mobile-table-wrapper > [id*="GridView"] {
        min-width: 700px !important;
    }

    /* Prevent parent containers from blocking scroll */
    .mobile-table-wrapper * {
        max-width: none;
    }
}

/* Alternative: Simple data table wrapper (for simpler cases) */
.data-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    width: 100%;
}

.data-table::-webkit-scrollbar {
    height: 6px;
}

.data-table::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

/* GridView Default Styling - Apply to ALL GridViews */
.gridview-table,
table[id*="GridView"] {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.gridview-table th,
table[id*="GridView"] th {
    background: linear-gradient(135deg, #5D4037 0%, #8D6E63 100%);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.gridview-table td,
table[id*="GridView"] td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.gridview-table tr:hover,
table[id*="GridView"] tr:hover {
    background: #FFF8E1;
}

.gridview-table tr:nth-child(even),
table[id*="GridView"] tr:nth-child(even) {
    background: #fafafa;
}

.gridview-table tr:nth-child(even):hover,
table[id*="GridView"] tr:nth-child(even):hover {
    background: #FFF8E1;
}

/* Action Buttons in Table - Mobile Friendly */
.table-actions {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    justify-content: center;
}

.table-actions .btn,
.table-actions button,
.table-actions input[type="button"],
.table-actions input[type="submit"] {
    min-width: 36px;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 6px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .table-actions .btn,
    .table-actions button,
    .table-actions input[type="button"],
    .table-actions input[type="submit"] {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }

    /* Reduce padding in table cells on mobile */
    .gridview-table td,
    .gridview-table th,
    table[id*="GridView"] td,
    table[id*="GridView"] th {
        padding: 10px 8px;
        font-size: 13px;
    }
}

/* Standard Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.success { background: #E8F5E9; color: #2E7D32; }
.status-badge.warning { background: #FFF3E0; color: #E65100; }
.status-badge.danger { background: #FFEBEE; color: #C62828; }
.status-badge.info { background: #E3F2FD; color: #1565C0; }
.status-badge.primary { background: #EFEBE9; color: #5D4037; }

/* Price/Amount Display */
.amount-display {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-align: right;
}

.amount-positive { color: #2E7D32; }
.amount-negative { color: #C62828; }

/* Mobile Form Inputs - Prevent iOS Zoom */
@media (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="search"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        min-height: 44px; /* Touch-friendly height */
    }

    /* Make buttons more tappable */
    button,
    input[type="button"],
    input[type="submit"],
    .btn {
        min-height: 44px;
        padding: 12px 16px;
    }
}

/* Card Container for Mobile */
.card-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, #5D4037, #8D6E63);
    color: white;
    padding: 15px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

@media (max-width: 768px) {
    .card-container {
        border-radius: 0;
        margin-left: -15px;
        margin-right: -15px;
    }

    .card-body {
        padding: 15px;
    }
}

/* Loading/Processing Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #5D4037;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h4 {
    margin: 0 0 10px 0;
    color: #333;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

