/* ระบบ Track การส่งตัวอย่างเลือด - Modern UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    cursor: pointer;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #2563eb;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-stat {
    background: #fee2e2;
    color: #991b1b;
}

.badge-normal {
    background: #dbeafe;
    color: #1e40af;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-accepted {
    background: #dbeafe;
    color: #1e40af;
}

.badge-picked-up {
    background: #ddd6fe;
    color: #5b21b6;
}

.badge-delivered {
    background: #d1fae5;
    color: #065f46;
}

.badge-completed {
    background: #d1fae5;
    color: #065f46;
}

.header {
    background: white;
    box-shadow: var(--shadow-md);
    padding: 16px 0;
    margin-bottom: 30px;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--primary);
    font-weight: 600;
}

/* Settings Dropdown */
/* Settings Dropdown */
.settings-dropdown {
    position: relative;
    display: inline-block;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-600);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.settings-btn:hover {
    background: white;
    color: var(--primary);
    transform: rotate(90deg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 50px;
    background-color: white;
    min-width: 220px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    z-index: 100;
    overflow: hidden;
    border: 1px solid var(--gray-100);
    transform-origin: top right;
    animation: dropdownSlideIn 0.2s ease-out forwards;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dropdown-content a {
    color: var(--gray-700);
    padding: 14px 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 1px solid var(--gray-50);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: var(--gray-50);
    color: var(--primary);
    padding-left: 24px;
}

.settings-dropdown:hover .dropdown-content {
    display: block;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

.table tr:hover {
    background: var(--gray-50);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    color: var(--gray-600);
    font-size: 14px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scanner Container */
.scanner-container {
    text-align: center;
    padding: 40px;
}

.scanner-box {
    border: 3px dashed var(--gray-300);
    border-radius: 12px;
    padding: 60px;
    margin: 30px 0;
    background: var(--gray-50);
}

.scanner-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 30px;
}

/* Responsive */

/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Table responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .container {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 32px;
    }

    .header-content {
        padding: 0 16px;
    }

    .logo {
        font-size: 20px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .card {
        padding: 16px;
        border-radius: 10px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 28px;
    }

    .stat-label {
        font-size: 12px;
    }

    /* Header responsive */
    .header {
        padding: 12px 0;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 12px;
    }

    .logo {
        font-size: 18px;
        flex: 1;
    }

    .nav-toggle {
        display: flex;
        order: 2;
    }

    .nav {
        display: none;
        width: 100%;
        order: 3;
        flex-direction: column;
        gap: 0;
        background: white;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--gray-200);
        margin-left: 0;
        /* Reset margin */
    }

    .nav.active {
        display: flex;
    }

    .nav a,
    .nav span {
        padding: 12px 0;
        border-bottom: 1px solid var(--gray-100);
        font-size: 14px;
    }

    .nav a:last-child {
        border-bottom: none;
    }

    .nav #userName {
        display: block;
    }

    /* === COMPACT HEADER (Dispatcher) === */
    .header-compact .header-content {
        flex-wrap: nowrap;
        gap: 10px;
        align-items: center;
    }

    .header-compact .logo {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60%;
        flex: unset;
        /* Don't grow */
    }

    .header-compact .nav-toggle {
        display: none !important;
    }

    .header-compact .nav {
        display: flex !important;
        width: auto;
        order: 2;
        flex-direction: row;
        gap: 12px;
        background: transparent;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        align-items: center;
        flex-shrink: 0;
        margin-left: auto;
        /* Push to right */
    }

    .header-compact .nav a,
    .header-compact .nav span {
        padding: 6px 10px;
        border-bottom: none;
        background: var(--gray-100);
        border-radius: 20px;
    }

    .header-compact .nav a.active,
    .header-compact .nav a:hover {
        background: var(--primary);
        color: white;
    }

    .header-compact .nav #userName {
        display: none;
    }

    .header-compact .nav-text {
        display: none;
    }

    .header-compact .nav a[href="job-list"]>div {
        margin-left: 0 !important;
    }

    /* Table responsive */
    .table {
        font-size: 14px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Forms */
    .form-control {
        padding: 14px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }

    /* Login */
    .login-card {
        padding: 30px 24px;
        margin: 10px;
    }

    .login-title {
        font-size: 22px;
    }

    /* Job cards layout */
    .card>div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .card>div[style*="display: flex"][style*="gap: 12px"] {
        flex-wrap: wrap;
    }

    .card>div[style*="display: flex"][style*="gap: 12px"] .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Scanner */
    .scanner-box {
        padding: 30px 20px;
    }

    .scanner-icon {
        font-size: 48px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 10px;
    }

    .card {
        padding: 14px;
        margin-bottom: 14px;
        border-radius: 8px;
    }

    h1 {
        font-size: 20px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    h3 {
        font-size: 16px !important;
    }

    /* Stats grid - single column on small phones */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    .stat-value {
        font-size: 24px;
        margin-bottom: 0;
        order: 2;
    }

    .stat-label {
        order: 1;
        font-size: 13px;
    }

    /* Header */
    .header {
        padding: 10px 0;
        margin-bottom: 16px;
    }

    .header-content {
        padding: 0 10px;
    }

    .logo {
        font-size: 16px;
    }

    /* Table - card style on mobile */
    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
    }

    .table td {
        padding: 6px 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        margin-right: 12px;
        flex-shrink: 0;
    }

    .table tr:hover {
        background: white;
    }

    /* Forms - larger touch targets */
    .form-group {
        margin-bottom: 16px;
    }

    .form-label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .form-control {
        padding: 16px;
        font-size: 16px;
        border-radius: 8px;
    }

    .form-check {
        padding: 12px 0;
    }

    .form-check input[type="checkbox"],
    .form-check input[type="radio"] {
        width: 24px;
        height: 24px;
        margin-right: 12px;
    }

    .form-check label {
        font-size: 15px;
    }

    /* Buttons - full width on mobile */
    .btn {
        padding: 16px;
        font-size: 16px;
        border-radius: 8px;
    }

    .btn:not(.btn-block) {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Badges */
    .badge {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Alerts */
    .alert {
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* Login page */
    .login-container {
        padding: 16px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .login-title {
        font-size: 20px;
        margin-bottom: 24px;
    }

    /* Scanner */
    .scanner-container {
        padding: 20px 10px;
    }

    .scanner-box {
        padding: 24px 16px;
        margin: 16px 0;
    }

    .scanner-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }

    .scanner-box h3 {
        font-size: 14px !important;
    }

    /* Job cards */
    .card[style*="border-left"] {
        border-left-width: 3px !important;
    }

    /* Info boxes */
    div[style*="background: var(--gray-50)"] {
        padding: 14px !important;
        border-radius: 8px !important;
    }

    /* Action buttons in cards */
    div[style*="display: flex"][style*="gap: 12px"][style*="margin-top"] {
        flex-direction: column !important;
        gap: 8px !important;
    }

    div[style*="display: flex"][style*="gap: 12px"][style*="margin-top"] .btn {
        width: 100% !important;
        margin-bottom: 0 !important;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }

    .card {
        padding: 12px;
    }

    .login-card {
        padding: 20px 16px;
    }

    .login-title {
        font-size: 18px;
    }

    .stat-value {
        font-size: 22px;
    }

    .btn {
        padding: 14px;
        font-size: 15px;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .login-container {
        padding-top: 20px;
        align-items: center;
    }

    .login-card {
        max-width: 500px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Print styles */
@media print {

    .header,
    .nav,
    .btn,
    .nav-toggle {
        display: none !important;
    }

    body {
        background: white;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}