/* assets/css/style.css - Mobile-First & Desktop Optimized Layout */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #1e3a8a;
    --primary-light: #2563eb;
    --primary-dark: #0f172a;
    --accent-color: #0284c7;
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --danger-color: #dc2626;
    --bg-light: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Sarabun', 'Prompt', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 16px;
    padding-bottom: 90px; /* Space for mobile bottom bar */
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
header {
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
    color: #ffffff;
    padding: 12px 0;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #ffffff;
    flex-shrink: 0;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: #93c5fd;
    display: block;
    white-space: nowrap;
}

/* Navigation Links (Desktop) */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item a {
    color: #e2e8f0;
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.nav-item a:hover, .nav-item a.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.btn-quick-scan {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Mobile Bottom Navigation Bar (iOS / Android App Style) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
}

.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.725rem;
    font-weight: 500;
    width: 20%;
    gap: 2px;
    transition: color 0.2s ease;
}

.mobile-nav-link svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-link.active {
    color: var(--primary-light);
    font-weight: 700;
}

/* Floating Center Scan Button for Mobile */
.mobile-scan-fab {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    margin-top: -22px;
    border: 3px solid #ffffff;
    transition: transform 0.2s ease;
}

.mobile-scan-fab:active {
    transform: scale(0.92);
}

/* Main Content Layout */
main {
    padding: 24px 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.page-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.stat-card:active, .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-info .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
}

.stat-info .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-ready .stat-icon { background: #dcfce7; color: #16a34a; }
.stat-wash .stat-icon { background: #ffedd5; color: #ea580c; }
.stat-use .stat-icon { background: #dbeafe; color: #2563eb; }
.stat-other .stat-icon { background: #fee2e2; color: #dc2626; }

/* Mobile Simplified Quick Roles */
.workflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.workflow-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 16px;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.workflow-card:active {
    background: #f8fafc;
    transform: scale(0.98);
}

.workflow-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.workflow-title {
    font-size: 1rem;
    font-weight: 700;
}

.workflow-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Card Wrapper */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 24px;
}

.card-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Table Responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    margin-bottom: 10px;
    max-width: 100%;
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

.table-custom th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    padding: 11px 14px;
    font-size: 0.875rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table-custom td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 0.925rem;
    white-space: nowrap;
}

/* Allow text wrapping only in specific detailed description columns */
.table-custom td.col-desc {
    white-space: normal;
    min-width: 180px;
}

/* Code & Links badges */
.nowrap, .code-link, .tank-code-link {
    white-space: nowrap !important;
    display: inline-block;
}

/* Forms & Buttons for Mobile */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.925rem;
    color: var(--text-main);
}

.form-control, .form-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    min-height: 48px; /* Touch target size */
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
    line-height: 1.35;
    transition: all 0.15s ease;
}

.btn-primary { background-color: var(--primary-light); color: #ffffff; }
.btn-primary:active { background-color: #1d4ed8; }

.btn-success { background-color: var(--success-color); color: #ffffff; }
.btn-success:active { background-color: #15803d; }

.btn-warning { background-color: var(--warning-color); color: #ffffff; }
.btn-warning:active { background-color: #c2410c; }

.btn-outline { background-color: transparent; border: 1.5px solid var(--border-color); color: var(--text-main); }
.btn-outline:active { background-color: #f1f5f9; }

.btn-block { width: 100%; }

/* Status Banners */
.status-banner {
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1.5px solid;
}

.status-banner-1 { background: #dcfce7; color: #14532d; border-color: #86efac; }
.status-banner-2 { background: #ffedd5; color: #7c2d12; border-color: #fdba74; }
.status-banner-3 { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
.status-banner-4 { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }

/* Camera Scanner Full UI & Laser Overlay */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background: #000000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.scanner-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scanner-target {
    width: 220px;
    height: 220px;
    border: 3px solid #10b981;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.5);
}

.scanner-laser {
    width: 100%;
    height: 2px;
    background: #10b981;
    box-shadow: 0 0 12px #10b981;
    position: absolute;
    top: 0;
    animation: scanAnim 2s infinite ease-in-out;
}

@keyframes scanAnim {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Modal Camera Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 14px;
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: #ffffff;
    border-radius: 20px;
    max-width: 520px;
    width: 95%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 22px;
    box-shadow: var(--shadow-lg);
    position: relative;
    margin: auto;
}

/* Tablet Responsive (Medium screens 769px - 1100px) */
@media (max-width: 1100px) and (min-width: 769px) {
    .nav-item a {
        padding: 6px 9px;
        font-size: 0.825rem;
        gap: 3px;
    }
    .brand-title {
        font-size: 0.95rem;
    }
    .brand-subtitle {
        font-size: 0.7rem;
    }
}

/* Mobile responsive media queries */
@media (max-width: 768px) {
    body {
        padding-bottom: 80px;
        font-size: 15px;
    }

    .container {
        padding: 0 12px;
    }
    
    .nav-menu {
        display: none; /* Hide top menu on mobile, replaced by bottom bar */
    }
    
    .mobile-bottom-nav {
        display: flex; /* Show app bottom bar */
        height: 60px;
    }

    .brand-title {
        font-size: 0.9rem;
    }
    .brand-subtitle {
        display: none; /* Hide subtitle on mobile top bar for compact view */
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .page-desc {
        font-size: 0.825rem;
    }

    .btn {
        padding: 10px 12px;
        font-size: 0.875rem;
        min-height: 44px;
        width: 100%; /* Stretched clean touch buttons on mobile */
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        text-align: center;
        line-height: 1.3;
    }

    .btn-block {
        width: 100%;
    }

    .form-control, .form-select {
        padding: 10px 12px;
        font-size: 0.925rem;
        min-height: 42px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .stat-card {
        padding: 10px 12px;
    }
    
    .stat-info .stat-value {
        font-size: 1.3rem;
    }
    
    .workflow-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .workflow-card {
        padding: 12px;
        gap: 10px;
    }
    
    .workflow-icon {
        width: 40px;
        height: 40px;
    }

    .workflow-title {
        font-size: 0.9rem;
    }
    
    .content-card {
        padding: 12px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .card-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 12px;
    }

    .modal-box {
        padding: 14px;
        max-height: 92vh;
        border-radius: 16px;
    }
}
