/* APS System Styles */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.login-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.card {
    border: none;
    border-radius: 15px;
}

.card-body {
    padding: 2rem;
}

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(45deg, #0056b3, #004085);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.table {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table-dark {
    background: linear-gradient(45deg, #343a40, #495057);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 123, 255, 0.05);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.1);
    transition: background-color 0.3s ease;
}

.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.5rem;
}

.alert-info {
    background: linear-gradient(45deg, #d1ecf1, #bee5eb);
    color: #0c5460;
}

.alert-danger {
    background: linear-gradient(45deg, #f8d7da, #f5c6cb);
    color: #721c24;
}

.spinner-border {
    color: #007bff;
}

.shadow-lg {
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
}

/* Animation for loading */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Data Table Enhancements */
.table-container {
    position: relative;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table-small {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f4;
}

.text-truncate-custom {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
}

.badge-success {
    background: linear-gradient(45deg, #28a745, #20c997);
}

.badge-warning {
    background: linear-gradient(45deg, #ffc107, #fd7e14);
    color: #212529;
}

.badge-danger {
    background: linear-gradient(45deg, #dc3545, #e83e8c);
}

.badge-info {
    background: linear-gradient(45deg, #17a2b8, #6f42c1);
}

/* Tooltip Styles */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
}

/* Modal Enhancements */
.modal-dialog {
    margin: 1rem;
}

.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    border-radius: 15px 15px 0 0;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 15px 15px;
}

/* QR Scanner Styles */
.btn-qr {
    background: linear-gradient(45deg, #28a745, #20c997);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.btn-qr:hover {
    background: linear-gradient(45deg, #20c997, #17a2b8);
    color: white;
    transform: scale(1.05);
}

.btn-qr:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.qr-scanner-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

#qr-video {
    width: 100%;
    height: auto;
    min-height: 300px;
    border-radius: 10px;
}

.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(0, 255, 0, 0.7);
    border-radius: 10px;
    pointer-events: none;
    z-index: 10;
}

.qr-scan-line {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
    animation: qr-scan 2s linear infinite;
}

@keyframes qr-scan {
    0% { top: 20%; opacity: 1; }
    50% { opacity: 0.8; }
    100% { top: 80%; opacity: 1; }
}

#qr-placeholder {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px dashed #6c757d;
    border-radius: 10px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.qr-controls {
    margin-top: 15px;
    text-align: center;
}

.qr-controls .btn {
    margin: 0 5px;
    min-width: 120px;
}

.qr-result {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 1px solid #c3e6cb;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
}

.qr-error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
}

.search-highlight {
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* Mobile optimizations for QR scanner */
@media (max-width: 768px) {
    .qr-scanner-container {
        max-width: 90vw;
    }
    
    #qr-video {
        min-height: 250px;
    }
    
    .qr-controls .btn {
        min-width: 100px;
        font-size: 0.9rem;
    }
    
    .mobile-qr-modal .modal-dialog {
        max-width: 95vw;
        margin: 1rem auto;
    }
    
    #qr-placeholder {
        min-height: 200px;
    }
}

/* Enhanced table loading animation */
.table-loading {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.table-loading tbody {
    position: relative;
}

.table-loading tbody::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #28a745, #007bff);
    animation: table-loading 1s ease-in-out infinite;
}

@keyframes table-loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    white-space: nowrap;
    opacity: 0.8;
    animation: scrollHint 2s ease-in-out infinite;
}

@keyframes scrollHint {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Pull to Refresh Indicator */
.pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border-radius: 0 0 20px 20px;
    font-size: 0.875rem;
    z-index: 1000;
    transition: all 0.3s ease;
}

/* Loading Overlay Enhanced */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-overlay .spinner-border {
    color: #007bff;
    width: 3rem;
    height: 3rem;
}

/* Table Enhancement for Mobile */
.table-responsive::after {
    content: "← เลื่อนซ้าย-ขวาเพื่อดูข้อมูลเพิ่มเติม →";
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    .table-responsive::after {
        opacity: 1;
    }
}

/* Status Badge Enhancements */
.badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.badge.bg-success {
    background: linear-gradient(45deg, #28a745, #20c997) !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.badge.bg-warning {
    background: linear-gradient(45deg, #ffc107, #fd7e14) !important;
    color: #212529 !important;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.badge.bg-danger {
    background: linear-gradient(45deg, #dc3545, #e83e8c) !important;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.badge.bg-info {
    background: linear-gradient(45deg, #17a2b8, #6f42c1) !important;
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}
