/* Modern Theme - Clean & Professional Design */
/* Color Palette */
:root {
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --primary-hover: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #6366f1;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Cross-Platform Variables */
    /* Touch Targets - WCAG 2.5.5 Compliance */
    --touch-target-min: 48px;
    --touch-target-comfortable: 56px;

    /* Platform-Specific Safe Areas */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);

    /* Z-Index Hierarchy */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 1000;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 2000;
    --z-overlay: 3000;
}

* {
    font-family: "Noto Sans Thai", "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Modern Card Styles */
.card {
    border: none;
    border-radius: 16px;
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 2px solid var(--border-color);
    padding: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

/* Modern Button Styles */
.btn {
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
    border: none;
    touch-action: manipulation;
}

/* Platform-Specific Font Optimization */
@supports (-webkit-touch-callout: none) {
    * {
        -webkit-font-smoothing: antialiased;
    }
}

@supports (-moz-appearance: none) {
    * {
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Material Design Touch Targets */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .form-control,
    .nav-link,
    .dropdown-item,
    button,
    a {
        min-height: var(--touch-target-min) !important;
        min-width: var(--touch-target-min) !important;
    }
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
}

.btn-light {
    background: #f8fafc;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-light:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.125rem;
    border-radius: 12px;
}

/* Modern Form Styles */
.form-control {
    border-radius: 10px;
    border: 2px solid var(--border-color);
    /* padding: 0.625rem 1rem; */
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-select {
    border-radius: 10px;
    border: 2px solid var(--border-color);
    /* padding: 0.625rem 1rem; */
    transition: all 0.3s ease;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
    outline: none;
}

/* Modern Table Styles */
.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table thead th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* .table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.01);
} */


.table td {
    /* padding: 1rem; */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Modern Badge Styles */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: var(--primary-gradient);
    color: white;
}

.badge-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.badge-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.badge-info {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

/* Modern Input Group */
.input-group-text {
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 10px 0 0 10px;
    color: var(--text-secondary);
}

.input-group .form-control {
    border-radius: 0 10px 10px 0;
}

.input-group .form-control:first-child {
    border-radius: 10px 0 0 10px;
}

.input-group .form-control:last-child {
    border-radius: 0 10px 10px 0;
}

/* Modern Dropdown */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 8px;
    padding: 0.625rem 1rem;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.dropdown-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

/* Modern Modal */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 2px solid var(--border-color);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 2px solid var(--border-color);
    padding: 1.5rem;
}

/* Modern Alert */
.alert {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    border-left: 4px solid;
}

.alert-primary {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary-color);
    color: var(--primary-dark);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--success-color);
    color: #059669;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: var(--warning-color);
    color: #d97706;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--danger-color);
    color: #dc2626;
}

/* Modern Pagination */
.page-link {
    border: none;
    border-radius: 8px;
    margin: 0 0.125rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.page-link:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-2px);
}

.page-item.active .page-link {
    background: var(--primary-gradient);
    color: white;
}

/* Modern Progress Bar */
.progress {
    height: 0.75rem;
    border-radius: 10px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar {
    background: var(--primary-gradient);
    transition: width 0.6s ease;
}

/* Modern Tooltip */
.tooltip-inner {
    background: var(--text-primary);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

/* Modern Nav Tabs */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-secondary);
    border-radius: 10px 10px 0 0;
    padding: 0.75rem 1.25rem;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.nav-tabs .nav-link.active {
    background: var(--primary-gradient);
    color: white;
}

/* Modern Card Stats */
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border-left: 4px solid;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-card.primary {
    border-left-color: var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Animation Utilities */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Gradient Text */
.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Modern Sidebar */
.sidebar {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

.sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 10px;
    margin: 0.25rem 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    background: rgba(59, 130, 246, 0.1);
    color: white;
    transform: translateX(4px);
}

.sidebar .nav-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-brand {
    color: white !important;
    font-weight: 700;
    font-size: 1.25rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Modern Topbar */
.topbar {
    background: white !important;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
}

/* Scroll to Top Button */
.scroll-to-top {
    background: var(--primary-gradient);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.scroll-to-top:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    color: white;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 1rem;
    }

    .card {
        border-radius: 12px;
    }

    .btn {
        padding: 0.5rem 1rem;
    }
}

/* Loading Spinner */
.spinner-border-modern {
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modern Checkbox */
.form-check-input {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    width: 1.25rem;
    height: 1.25rem;
    transition: all 0.2s ease;
}

.form-check-input:checked {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
}

/* Modern Radio Button */
.form-check-input[type="radio"] {
    border-radius: 50%;
}

/* Divider */
.divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 1.5rem 0;
}

/* Shadow Utilities */
.shadow-custom {
    box-shadow: var(--shadow-md);
}

.shadow-custom-lg {
    box-shadow: var(--shadow-lg);
}

/* Border Utilities */
.border-custom {
    border: 2px solid var(--border-color);
}

.border-custom-top {
    border-top: 2px solid var(--border-color);
}

.border-custom-bottom {
    border-bottom: 2px solid var(--border-color);
}

/* Text Utilities */
.text-primary-custom {
    color: var(--primary-color);
}

.text-secondary-custom {
    color: var(--text-secondary);
}

/* Background Utilities */
.bg-primary-custom {
    background: var(--primary-gradient);
}

.bg-light-custom {
    background: var(--bg-color);
}

/* ========================================
   CROSS-PLATFORM OPTIMIZATIONS
   ======================================== */

/* Android Address Bar Handling */
html {
    overscroll-behavior-y: none;
}

body {
    overscroll-behavior: none;
}

/* Prevent pull-to-refresh on Android */
.no-pull-refresh {
    overscroll-behavior-y: contain;
}

/* iOS Safari 100vh Fix */
.full-height-ios {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.ios-viewport-fix {
    height: 100vh;
    height: -webkit-fill-available;
}

/* Cross-Platform Images */
img {
    max-width: 100%;
    height: auto;
    -webkit-object-fit: cover;
    object-fit: cover;
}

/* Responsive video */
video {
    max-width: 100%;
    height: auto;
}

/* Barcode scanner iOS fix */
.barcode-scanner video {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ========================================
   PLATFORM-SPECIFIC MEDIA QUERIES
   ======================================== */

/* iOS Safari Specific Fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix iOS input zoom */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Fix iOS modal positioning */
    .modal {
        -webkit-overflow-scrolling: touch;
    }

    /* Fix iOS checkbox styling */
    input[type="checkbox"] {
        -webkit-appearance: none;
        width: 22px;
        height: 22px;
    }
}

/* Android Chrome Specific Fixes */
@supports not (-webkit-touch-callout: none) and (hover: none) {
    /* Fix Android button styling */
    .btn {
        letter-spacing: 0.5px;
    }

    /* Fix Android select styling */
    select {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* Firefox Specific Fixes */
@supports (-moz-appearance: none) {
    /* Firefox scrollbar */
    * {
        scrollbar-width: thin;
        scrollbar-color: rgba(59, 130, 246, 0.5) transparent;
    }
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Extra small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    .card {
        border-radius: 12px;
    }

    .btn {
        padding: 0.5rem 1rem;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .card {
        border-radius: 14px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .card {
        border-radius: 16px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Tablet Landscape Optimization */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }

    .card {
        margin-bottom: 1rem;
    }
}

/* Large Desktop Optimization */
@media (min-width: 1600px) {
    .container {
        max-width: 1500px;
    }

    .card {
        border-radius: 20px;
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {
    /* Touch-specific optimizations */
    .btn {
        min-height: var(--touch-target-min) !important;
        min-width: var(--touch-target-min) !important;
    }

    .form-control,
    .nav-link,
    .dropdown-item,
    button,
    a {
        min-height: var(--touch-target-min) !important;
        min-width: var(--touch-target-min) !important;
    }
}

/* ========================================
   CROSS-PLATFORM PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
        color: black;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}
