/* =====================================================
   ระบบติดตามการส่งเอกสาร - Bootstrap 5 + Sarabun
   Document Tracking System
   ===================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif !important;
    background-color: #f8f9fa;
    font-size: 13px;
    color: #1f2937;
    zoom: 0.9;
}

/* =====================================================
   Modern Responsive Enhancements
   ===================================================== */

/* Smooth transitions */
.card, .btn, .form-control, .form-select, .table {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card hover effects */
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.15) !important;
}

/* Button enhancements */
.btn {
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.5rem 1.25rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Form control improvements */
.form-control:focus, .form-select:focus {
    border-color: #1e40af;
    box-shadow: 0 0 0 0.25rem rgba(30, 64, 175, 0.15);
    transform: translateY(-1px);
    background-color: #ffffff;
}

.form-control, .form-select {
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    color: #1e293b;
    font-weight: 500;
}

.form-control::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.form-label {
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Input and select hover states */
.form-control:hover:not(:focus),
.form-select:hover:not(:focus) {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Table responsive improvements */
@media (max-width: 768px) {
    .table-responsive {
        border-radius: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table thead th {
        font-size: 0.85rem;
        padding: 0.75rem 0.5rem !important;
        white-space: nowrap;
    }
    
    .table tbody td {
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem !important;
    }
}

/* Status badges with icons */
.badge {
    padding: 0.5rem 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    font-size: 0.875rem;
}

/* Gradient backgrounds */
.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.bg-gradient-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%) !important;
}

.bg-gradient-info {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%) !important;
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%) !important;
}

/* Mobile responsive utilities */
@media (max-width: 576px) {
    .card-body {
        padding: 1rem !important;
    }
    
    h2, .h2 {
        font-size: 1.5rem !important;
    }
    
    h5, .h5 {
        font-size: 1.1rem !important;
    }
    
    .btn-group-sm > .btn, .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 992px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Modal improvements */
.modal-content {
    border: none;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
}

.modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-fullscreen {
        margin: 0;
    }
}

/* Pagination improvements */
.pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    font-weight: 600;
    border: 1px solid #dee2e6;
    color: #667eea;
}

.pagination .page-link:hover {
    background-color: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background-color: #667eea;
    border-color: #667eea;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.spinner-border {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Card entrance animation */
.card {
    animation: fadeIn 0.6s ease-out;
}

.card:nth-child(1) {
    animation-delay: 0.1s;
}

.card:nth-child(2) {
    animation-delay: 0.2s;
}

.card:nth-child(3) {
    animation-delay: 0.3s;
}

.card:nth-child(4) {
    animation-delay: 0.4s;
}

/* Statistics cards animation */
.row.g-3 > [class*="col"]:nth-child(1) .card {
    animation: slideInFromLeft 0.6s ease-out;
}

.row.g-3 > [class*="col"]:nth-child(2) .card {
    animation: fadeIn 0.6s ease-out 0.1s;
    animation-fill-mode: backwards;
}

.row.g-3 > [class*="col"]:nth-child(3) .card {
    animation: fadeIn 0.6s ease-out 0.2s;
    animation-fill-mode: backwards;
}

.row.g-3 > [class*="col"]:nth-child(4) .card {
    animation: slideInFromRight 0.6s ease-out 0.3s;
    animation-fill-mode: backwards;
}

/* Table row animation */
tbody tr {
    animation: fadeIn 0.4s ease-out;
}

/* Button hover effect */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

/* Icon bounce on hover */
.bi {
    display: inline-block;
    transition: transform 0.3s ease;
}

.btn:hover .bi,
.card:hover .bi {
    transform: scale(1.1);
}

/* Smooth focus effect */
.form-control:focus,
.form-select:focus {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.spinner-border {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Shadow utilities */
.shadow-sm {
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1) !important;
}

.shadow {
    box-shadow: 0 4px 12px -3px rgba(0, 0, 0, 0.15) !important;
}

.shadow-lg {
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.2) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* =====================================================
   Enhanced Table Styles for Mobile
   ===================================================== */

/* Table styling improvements */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

/* Force gradient background on thead tr */
.table thead tr {
    background: linear-gradient(135deg, #1e3a8a 0%, #6366f1 100%) !important;
}

/* Prevent th from overriding gradient */
.table thead th {
    padding: 1rem 0.85rem !important;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 700 !important;
    border: none !important;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    background: transparent !important;
}

/* Ensure all text and icons in thead are white */
.table thead th,
.table thead th i,
.table thead th .bi {
    color: #ffffff !important;
}

/* Icon styling in header */
.table thead th i {
    font-weight: bold;
    opacity: 1;
}

.table tbody tr {
    border-bottom: 2px solid #f1f5f9;
    transition: all 0.3s ease;
    background-color: #ffffff;
}

.table tbody tr:hover {
    background-color: #f8fafc !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.08);
}

.table tbody td {
    padding: 1rem 0.85rem;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.9rem;
    vertical-align: middle;
    background-color: #ffffff;
    border-bottom: 2px solid #f1f5f9;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Alternating row colors for better readability */
.table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.table tbody tr:nth-child(even):hover {
    background-color: #f8fafc !important;
}

.table tbody tr:nth-child(even) td {
    background-color: #fafbfc;
}

/* Mobile-friendly table actions */
@media (max-width: 768px) {
    .table .actions {
        white-space: nowrap;
    }
    
    .table .actions .btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .table .actions .btn i {
        font-size: 1rem;
    }
    
    /* Hide less important columns on mobile */
    .table .d-none.d-md-table-cell {
        display: none !important;
    }
    
    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* Status badges enhancement */
.badge {
    padding: 0.5rem 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
}

.badge.bg-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge.bg-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge.bg-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge.bg-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Action buttons enhancement */
.btn-outline-primary {
    color: #1e40af;
    border-color: #1e40af;
    font-weight: 600;
}

.btn-outline-primary:hover {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border-color: #1e40af;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 64, 175, 0.25);
}

.btn-outline-info {
    color: #3b82f6;
    border-color: #3b82f6;
    font-weight: 600;
}

.btn-outline-info:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #3b82f6;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.25);
}

.btn-outline-danger {
    color: #ef4444;
    border-color: #ef4444;
    font-weight: 600;
}

.btn-outline-danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #ef4444;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.25);
}

/* Pagination enhancement */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 3px;
    font-weight: 700;
    border: 2px solid #e5e7eb;
    color: #1e40af;
    padding: 0.5rem 0.85rem;
    transition: all 0.2s ease;
}

.pagination .page-link:hover {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border-color: #1e40af;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 64, 175, 0.25);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border-color: #1e40af;
    box-shadow: 0 2px 4px rgba(30, 64, 175, 0.25);
}

.pagination .page-item.disabled .page-link {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
}

/* =====================================================
   Enhanced Table Styles for Mobile
   ===================================================== */

.glass-card {
    background: rgba(255, 255, 255, 0.86);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 18px 45px -25px rgba(15, 23, 42, 0.35);
    padding: 1.25rem;
}

.card.glass-card {
    padding: 0;
}

.hero-card {
    position: relative;
    overflow: hidden;
    padding: 1.75rem 2rem;
}

.hero-card::after {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.55), rgba(125, 211, 252, 0));
    filter: blur(0px);
}

.hero-card::before {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.45), rgba(59, 130, 246, 0));
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
}

.hero-title {
    font-size: clamp(1.75rem, 2.7vw, 2.5rem);
    color: #0f172a !important;
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1rem;
    color: #475569;
    max-width: 640px;
}

.hero-tags .badge {
    background: rgba(15, 23, 42, 0.06) !important;
    color: #1e293b;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
}

.hero-status {
    background: rgba(15, 23, 42, 0.05);
    border-radius: 18px;
    padding: 1rem 1.25rem;
    width: 100%;
}

.hero-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.hero-metric strong {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.hero-metric .caption {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.action-toolbar {
    border-radius: 20px;
    padding: 1.75rem 2rem;
}

.btn-lg-custom {
    padding: 0.65rem 1.25rem;
    border-radius: 14px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-lg-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -18px rgba(15, 23, 42, 0.45);
}

.btn-lg-custom i {
    font-size: 1rem;
}

.filter-card {
    border-radius: 20px;
}

.filter-chip {
    font-weight: 600;
    padding: 0.45rem 1.1rem;
}

.input-group-lg-custom .form-control,
.form-select-lg-custom,
.form-floating-lg-custom .form-control {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    font-size: 0.95rem;
}

.input-group-lg-custom .input-group-text {
    border-radius: 14px 0 0 14px;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.form-floating-lg-custom label {
    color: #64748b;
    font-weight: 500;
}

.stats-grid .col {
    display: flex;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.4rem 1.6rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.9);
    width: 100%;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.08), rgba(191, 219, 254, 0.08));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.metric-body {
    position: relative;
    z-index: 1;
}

.metric-label {
    display: block;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.12em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0.15rem 0;
}

.data-card {
    border-radius: 24px;
    overflow: hidden;
}

.card-header-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.bulk-edit-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.1rem 1.6rem;
    background: linear-gradient(135deg, rgba(254, 240, 138, 0.55), rgba(255, 251, 235, 0.8));
    border-top: 1px solid rgba(234, 179, 8, 0.35);
    border-bottom: 1px solid rgba(234, 179, 8, 0.35);
}

.table-modern {
    min-width: 1000px;
    font-size: 0.9rem;
}

.table-modern thead {
    background: linear-gradient(135deg, rgba(224, 242, 254, 0.95), rgba(191, 219, 254, 0.95));
}

.table-modern thead th {
    color: #0f172a !important;
    border: none;
    padding: 0.85rem 0.75rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.table-modern tbody tr {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.table-modern tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 999px rgba(148, 163, 184, 0.08);
}

.table-modern tbody td {
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    padding: 0.85rem 0.75rem;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.card-footer select {
    border-radius: 12px;
}

.bulk-edit-toolbar .btn {
    border-radius: 999px;
    font-weight: 600;
}

@media (max-width: 991px) {
    .hero-status {
        align-items: stretch !important;
    }

    .hero-metric {
        width: 100%;
        padding: 0.5rem 0.75rem;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.6);
    }
}

@media (max-width: 767px) {
    .glass-card {
        padding: 1.5rem;
    }

    .hero-card {
        padding: 2rem;
    }

    .btn-lg-custom {
        width: 100%;
    }

    .table-modern {
        min-width: 760px;
    }
}

@media (max-width: 575px) {
    .hero-subtitle {
        font-size: 0.95rem;
    }

    .metric-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .metric-icon {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
    }
}

/* Compact container */
.container-fluid {
    max-width: 1400px;
    padding-left: 15px;
    padding-right: 15px;
}

/* Reduce main padding */
main {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

/* Form controls */
.form-control, .form-select, input, textarea, select {
    color: #1f2937 !important;
}

.form-label, label {
    color: #374151 !important;
    font-weight: 500;
}

h1, h2, h3, h4, h5, h6 {
    color: #1e3a8a !important;
}

.text-muted {
    color: #64748b !important;
}

/* =====================================================
   Login Page
   ===================================================== */

.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.login-icon i {
    color: white;
}

/* =====================================================
   Custom Utilities
   ===================================================== */

.fw-medium {
    font-weight: 500 !important;
}

.text-decoration-none {
    text-decoration: none !important;
}

/* =====================================================
   Table Enhancements
   ===================================================== */

.table {
    font-size: 0.85rem;
    color: #1f2937;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    padding: 0.5rem;
    color: white;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.5rem;
    color: #374151;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* =====================================================
   Status Badges
   ===================================================== */

.badge-status {
    padding: 0.375rem 0.75rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-shipping {
    background-color: #cfe2ff;
    color: #084298;
}

.status-delivered {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #842029;
}

/* =====================================================
   Bulk Edit Mode
   ===================================================== */

.bulk-edit-column {
    width: 40px;
    text-align: center;
}

.editable-row {
    background-color: #fff3cd !important;
}

.editable-row [contenteditable="true"] {
    background-color: white;
    padding: 0.5rem;
    border: 2px solid #0d6efd;
    border-radius: 0.25rem;
    min-height: 38px;
    color: #1f2937;
}

.editable-row [contenteditable="true"]:focus {
    outline: none;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.inline-select {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    color: #1f2937;
}

/* =====================================================
   Pagination Custom
   ===================================================== */

.pagination-sm .page-link {
    font-size: 0.875rem;
}

/* =====================================================
   Bulk Add Table
   ===================================================== */

#bulkAddTable {
    min-width: 1200px;
}

#bulkAddTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#bulkAddTable .row-number {
    text-align: center;
    font-weight: 600;
    color: #6c757d;
    background-color: #f8f9fa;
}

.bulk-input,
.bulk-select {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

.bulk-input:focus,
.bulk-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Select2 styling for bulk add modal */
.bulk-customer-select + .select2-container {
    width: 100% !important;
}

.bulk-customer-select + .select2-container .select2-selection {
    height: auto !important;
    min-height: 31px;
    padding: 0.175rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

.bulk-customer-select + .select2-container .select2-selection:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.bulk-customer-select + .select2-container .select2-selection__rendered {
    padding: 0;
    line-height: 1.5;
}

.bulk-customer-select + .select2-container .select2-selection__arrow {
    height: 29px;
}

/* =====================================================
   Batch Rows (Expandable/Collapsible)
   ===================================================== */

.batch-row {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #1e3a8a;
}

.batch-row td {
    color: #1e3a8a !important;
    font-weight: 600;
}

.batch-row:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.15);
}

.batch-row .badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    font-weight: 700;
}

.batch-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 1rem;
    color: #1e40af;
    font-weight: bold;
}

.batch-detail-row {
    border-left: 3px solid #3b82f6;
    animation: slideDown 0.3s ease;
    background-color: #f8fafc;
}

.batch-detail-row td {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #1e293b !important;
    font-weight: 600;
    background-color: #f8fafc !important;
}

.batch-detail-row:hover {
    background-color: #f1f5f9 !important;
}

.batch-detail-row:hover td {
    background-color: #f1f5f9 !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   Alert Floating (Toast-like)
   ===================================================== */

.alert-floating {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    min-width: 350px;
    max-width: 500px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =====================================================
   Action Buttons
   ===================================================== */

.btn-icon {
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-edit:hover {
    color: #0dcaf0;
}

.btn-delete:hover {
    color: #dc3545;
}

/* =====================================================
   Card Shadows
   ===================================================== */

.card {
    border: none;
    color: #1f2937;
}

.card-body {
    padding: 1rem;
    color: #374151;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* =====================================================
   Navbar Customization
   ===================================================== */

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link.active {
    color: #fff;
}

/* =====================================================
   Statistics Cards Animation
   ===================================================== */

.card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.card h3 {
    font-size: 1.75rem;
}

.card .fs-1 {
    font-size: 2rem !important;
}

/* =====================================================
   Form Enhancements
   ===================================================== */

.form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* =====================================================
   Modal Enhancements
   ===================================================== */

.modal-header {
    border-bottom: 2px solid #dee2e6;
}

.modal-footer {
    border-top: 2px solid #dee2e6;
}

/* =====================================================
   Responsive Adjustments
   ===================================================== */

@media (max-width: 768px) {
    .alert-floating {
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .btn {
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    body {
        font-size: 14px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
}

/* =====================================================
   Print Styles
   ===================================================== */

@media print {
    .navbar,
    .btn,
    .pagination,
    .modal {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* =====================================================
   Loading Spinner
   ===================================================== */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* =====================================================
   Custom Scrollbar
   ===================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* =====================================================
   View Detail Modal
   ===================================================== */

.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.detail-row {
    border-bottom: 1px solid #e9ecef;
    padding: 0.875rem 0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #475569;
    font-size: 0.875rem;
}

.detail-value {
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 500;
}

.print-section {
    page-break-inside: avoid;
}

/* Improved card hover for view modal */
#viewModal .card {
    transition: all 0.3s ease;
}

#viewModal .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Info badges with icons */
.bg-opacity-10 {
    --bs-bg-opacity: 0.1;
}

/* Enhanced modal styling */
.modal-xl {
    max-width: 1140px;
}

/* Modal animation */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Icon boxes animation */
.bg-opacity-10 {
    transition: all 0.3s ease;
}

.card:hover .bg-opacity-10 {
    transform: scale(1.05);
}

@media (max-width: 992px) {
    .modal-xl {
        max-width: 90%;
    }
}

@media print {
    /* ซ่อนทุกอย่างยกเว้นหน้าพิมพ์ */
    body > *:not(#printPage) {
        display: none !important;
    }
    
    #printPage {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 30px;
    }
    
    body {
        margin: 0;
        padding: 0;
        background: white;
    }
    
    /* Print Header with Gradient */
    #printPage .print-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color: white !important;
    }
    
    #printPage .print-header h1,
    #printPage .print-header p {
        color: white !important;
    }
    
    #printPage .logo-icon {
        background: rgba(255, 255, 255, 0.2) !important;
        border: 3px solid rgba(255, 255, 255, 0.3) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Info Badges with Gradients */
    #printPage .info-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        page-break-inside: avoid;
    }
    
    #printPage .icon-box {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Section Cards */
    #printPage .section-card {
        page-break-inside: avoid;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #e9ecef !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    #printPage .section-card .card-header {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Colors */
    .text-primary {
        color: #0d6efd !important;
    }
    
    .text-success {
        color: #198754 !important;
    }
    
    .text-info {
        color: #0dcaf0 !important;
    }
    
    .text-muted {
        color: #6c757d !important;
    }
    
    /* Status badges */
    .badge {
        border: 1px solid currentColor;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .badge.bg-warning {
        background-color: #ffc107 !important;
        color: #000 !important;
    }
    
    .badge.bg-info {
        background-color: #0dcaf0 !important;
        color: #000 !important;
    }
    
    .badge.bg-success {
        background-color: #198754 !important;
        color: #fff !important;
    }
    
    .badge.bg-danger {
        background-color: #dc3545 !important;
        color: #fff !important;
    }
    
    /* Footer */
    #printPage .print-footer {
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        page-break-inside: avoid;
    }
    
    /* Ensure all gradient backgrounds print */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* =====================================================
   Print Page (Hidden by default, shown only on print)
   ===================================================== */

#printPage {
    display: none;
}

#printPage .print-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    position: relative;
}

#printPage .print-header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
}

#printPage .print-header .logo-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

#printPage .print-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

#printPage .print-header p {
    font-size: 1.1rem;
    opacity: 0.95;
    margin: 0;
    letter-spacing: 1px;
}

#printPage .info-badge {
    text-align: center;
    padding: 25px;
    border-radius: 12px;
    transition: all 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#printPage .info-badge .icon-box {
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#printPage .info-badge .label {
    font-size: 0.85rem;
    color: #1a1a1a;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#printPage .info-badge .value {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.4;
    word-break: break-word;
    color: #1a1a1a;
}

#printPage .section-card {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#printPage .section-card .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-bottom: 2px solid #dee2e6;
}

#printPage .section-card .card-header h6 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #495057;
    margin: 0;
}

#printPage .section-card .card-body {
    padding: 25px;
}

#printPage .info-row {
    display: flex;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

#printPage .info-row:last-child {
    border-bottom: none;
}

#printPage .info-row .label-col {
    flex: 0 0 35%;
    font-weight: 600;
    color: #495057;
    font-size: 0.95rem;
}

#printPage .info-row .value-col {
    flex: 1;
    color: #212529;
    font-size: 1rem;
}

#printPage .print-footer {
    margin-top: 50px;
    padding: 25px 0;
    border-top: 3px double #dee2e6;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px 30px;
}

#printPage .print-footer .row {
    align-items: center;
}

#printPage .print-footer small {
    font-size: 0.9rem;
    color: #6c757d;
}

#printPage .print-footer .fw-bold {
    font-size: 1rem;
    color: #495057;
}

/* =====================================================
   Select2 Customization
   ===================================================== */

.select2-container--bootstrap-5 .select2-selection {
    font-family: 'Sarabun', sans-serif !important;
    font-size: 0.95rem;
}

.select2-container--bootstrap-5 .select2-dropdown {
    font-family: 'Sarabun', sans-serif !important;
    font-size: 0.95rem;
    z-index: 9999 !important;
}

/* Ensure Select2 dropdown appears above modal */
.select2-container {
    z-index: 9999 !important;
}

.modal .select2-container {
    z-index: 10000 !important;
}

.select2-dropdown {
    z-index: 10001 !important;
}

/* Custom customer option styling */
.customer-option {
    padding: 0.25rem 0;
}

.customer-option .fw-bold {
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.customer-option .small {
    font-size: 0.8rem;
    color: #6b7280 !important;
}

/* Highlight search term in Select2 results */
.select2-results__option--highlighted {
    background-color: #1e40af !important;
    color: white !important;
}

.select2-results__option--highlighted .small {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Loading state */
.select2-results__option--loading {
    color: #6b7280;
}

/* Input too short message */
.select2-results__message {
    color: #6b7280;
    font-style: italic;
    padding: 0.75rem;
}

/* =====================================================
   DataTables Batch Expand/Collapse
   ===================================================== */

/* Control icon for expandable batch rows - ใช้ชื่อใหม่เพื่อไม่ซ้ำกับ DataTables */
td.batch-control {
    /* background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23059669" viewBox="0 0 16 16"><path d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>') no-repeat center center; */
    cursor: pointer;
    padding: 0.5rem !important;
}

tr.shown td.batch-control {
    /* background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23059669" viewBox="0 0 16 16"><path d="M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708l6-6z"/></svg>') no-repeat center center; */
}

/* Batch details container */
.batch-details-container {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Child row styling */
table.dataTable tbody tr.child {
    background-color: #f8f9fa;
}

table.dataTable tbody tr.child:hover {
    background-color: #f1f5f9;
}

/* Batch row styling */
table.dataTable tbody tr[data-row-type="batch"] {
    background-color: #ecfdf5;
}

table.dataTable tbody tr[data-row-type="batch"]:hover {
    background-color: #d1fae5;
}
