@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --accent-color: #10b981;
    --theme-dark: #313a46;
    --primary-gradient: linear-gradient(135deg, #313a46 0%, #4a5568 100%);
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Outfit', sans-serif !important;
}

/* Glassmorphism Classes */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
}

/* Login Page Modernization */
.authentication-bg {
    background: url('../images/login_bg_modern.png') no-repeat center center fixed;
    background-size: cover;
}

#frmLogin .card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

#frmLogin .card-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#frmLogin .btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    transition: var(--transition);
}

#frmLogin .btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

#frmLogin .form-control {
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 12px 15px;
    transition: var(--transition);
}

#frmLogin .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Sidebar Modernization */
.leftside-menu {
    background: #0f172a !important;
    /* Slate 900 */
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.1);
}

.side-nav-link {
    color: #94a3b8 !important;
    font-weight: 500;
    margin: 4px 15px;
    border-radius: 10px;
    transition: var(--transition) !important;
}

.side-nav-link i {
    font-size: 1.1rem;
    margin-right: 10px;
}

.side-nav-link:hover,
.side-nav-item.active>.side-nav-link {
    color: #ffffff !important;
    background: rgba(99, 102, 241, 0.15);
}

.side-nav-title {
    color: #475569 !important;
    text-transform: uppercase;
    font-size: 0.7rem !important;
    letter-spacing: 1px;
    padding: 20px 25px 10px !important;
}

/* Navbar Modernization */
.navbar-custom {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
}

.account-user-name {
    font-weight: 600;
    color: #1e293b;
}

/* Tables & Cards in Main Content */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.table thead th {
    background-color: #f8fafc;
    color: white !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #f1f5f9;
}

/* Buttons */
.btn {
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #475569;
    border: none;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: #1e293b;
}

.modern-table-header {
    background: var(--theme-dark) !important;
    color: white !important;
}

.premium-card-header {
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.5rem !important;
}

.premium-card-header .card-title {
    color: var(--theme-dark) !important;
    margin-bottom: 0;
    font-weight: 600;
}

.modern-table-header th {
    color: white !important;
    font-weight: 600 !important;
    border: none !important;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modern Radio Cards */
.modern-radio-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.modern-radio-card {
    flex: 1;
    min-width: 140px;
    position: relative;
    margin-bottom: 0 !important;
}

.modern-radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-weight: 500;
    color: #64748b;
    height: 100%;
}

.modern-radio-card input[type="radio"]:checked+.radio-card-content {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

/* Specialized Status Colors */
.modern-radio-card.card-status-3 input[type="radio"]:checked+.radio-card-content {
    border-color: #10b981;
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.05);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.modern-radio-card.card-status-4 input[type="radio"]:checked+.radio-card-content {
    border-color: #ef4444;
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

.modern-radio-card.card-status-5 input[type="radio"]:checked+.radio-card-content {
    border-color: #3b82f6;
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.modern-radio-card:hover .radio-card-content {
    border-color: #cbd5e1;
}

/* Mobile Responsiveness Utilities */
@media (max-width: 768px) {
    .modern-radio-group {
        flex-direction: column;
        gap: 8px;
    }

    .modern-radio-card {
        min-width: 100%;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        border: 0;
    }
}

/* Modern Modal Enhancements */
.modern-modal-header {
    background: #313a46 !important;
    color: white !important;
    border-bottom: none;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modern-modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    margin: 0 !important;
}

.modern-modal-header .modal-title {
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
}

.modal-content {
    border: none !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-xl) !important;
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.5rem;
}

.btn-premium-primary {
    background: #212529 !important;
    border: 1px solid #212529 !important;
    color: white !important;
    padding: 0.6rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-premium-primary:hover {
    background: #343a40 !important;
    color: white !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.btn-premium-secondary {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    color: #212529 !important;
    padding: 0.6rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-premium-secondary:hover {
    background: #343a40 !important;
    border-color: #343a40 !important;
}

.btn-premium-success {
    background: #10b981 !important;
    border: 1px solid #10b981 !important;
    color: white !important;
    padding: 0.6rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-premium-success:hover {
    background: #059669 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
}

/* Modern Select2 Enhancements & Fix Gap */
.select2-container {
    position: relative;
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    background-color: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    height: 42px !important;
    transition: all 0.2s ease !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #475569 !important;
    line-height: 40px !important;
    padding-left: 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
    right: 8px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #94a3b8 transparent transparent transparent !important;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #94a3b8 transparent !important;
}

.select2-container--default .select2-selection--multiple {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    min-height: 42px !important;
    padding: 2px 0 !important;
}

.select2-container--open .select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden !important;
    z-index: 1060 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color) !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 8px !important;
    margin-bottom: 5px !important;
}

/* Status Buttons Styling */
.status-btn-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 5px;
    width: 100%;
}

.status-btn-item {
    flex: 1 1 0;
    /* Guarantee perfectly equal width regardless of content */
    min-width: 0;
    /* Allow flex to shrink below content width if needed */
    position: relative;
}

.status-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .5rem;
    font-size: .875rem;
    line-height: 1.5;
    border-radius: .2rem;
    font-weight: 400;
    cursor: pointer;
    transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
    text-align: center;
    border: 1px solid #ced4da;
    background-color: #f8f9fa;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    height: 31px;
    /* Typical height for btn-sm with line-height 1.5 */
}

.status-btn:hover:not(:disabled) {
    background-color: #e2e6ea;
    border-color: #dae0e5;
    color: #212529;
}

.status-btn:active:not(:disabled) {
    background-color: #dae0e5;
    border-color: #d3d9df;
}

/* Status Colors - ONLY shown when .active */

/* Status 3: เสร็จเรียบร้อย (#0ACF97) */
.status-btn-3:hover:not(:disabled):not(.active) {
    border-color: #0ACF97;
    color: #0ACF97;
}

.status-btn-3:active:not(:disabled),
.status-btn-3.active {
    background-color: #0ACF97 !important;
    border-color: #0ACF97 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(10, 207, 151, 0.3);
}

/* Status 4: ไม่สำเร็จ (#EB0B29) */
.status-btn-4:hover:not(:disabled):not(.active) {
    border-color: #EB0B29;
    color: #EB0B29;
}

.status-btn-4:active:not(:disabled),
.status-btn-4.active {
    background-color: #EB0B29 !important;
    border-color: #EB0B29 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(235, 11, 41, 0.3);
}

/* Status 5: ติดตั้งและทดสอบ (#0288d1) */
.status-btn-5:hover:not(:disabled):not(.active) {
    border-color: #0288d1;
    color: #0288d1;
}

.status-btn-5:active:not(:disabled),
.status-btn-5.active {
    background-color: #0288d1 !important;
    border-color: #0288d1 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(2, 136, 209, 0.3);
}