/* ============================================
   FiberRanger - Custom Styles
   ============================================ */

/* --- Base --- */
html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
    line-height: 1.6;
}

/* ผู้ใช้ 40+ — ตัวอักษรอ่านง่าย */
.btn, button, select, input, textarea {
    font-size: 14px;
}
h1 { font-size: 1.65rem !important; }
h2 { font-size: 1.35rem !important; }
table th, table td { font-size: 14px; padding: 10px 12px; }

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

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

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

/* --- Toast Animations --- */
@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-enter {
    animation: toast-slide-in 0.3s ease-out forwards;
}

.toast-exit {
    animation: toast-slide-out 0.3s ease-in forwards;
}

/* --- Modal Backdrop --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    transition: background 0.2s ease, backdrop-filter 0.2s ease;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

/* --- Loading Spinner --- */
@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
}

.loading-spinner.lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-spinner.sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Full page loading */
.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 1rem;
}

.loading-page .loading-spinner {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

/* --- Sidebar Transitions --- */
.sidebar {
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 40;
    transition: background 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    background: #f1f5f9;
    color: #334155;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #2563eb;
    font-weight: 600;
}

.sidebar-link.active i {
    color: #2563eb;
}

/* --- Status Badges --- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

/* Job Statuses */
.badge-status-pending {
    background: #fef9c3;
    color: #a16207;
    border: 1px solid #fde047;
}

.badge-status-assigned {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.badge-status-accepted {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #a5b4fc;
}

.badge-status-in_progress {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fdba74;
}

.badge-status-completed {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.badge-status-approved {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.badge-status-needs_revision {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.badge-status-cancelled {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

/* Priority Badges */
.badge-priority {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-priority-low {
    background: #f3f4f6;
    color: #4b5563;
}

.badge-priority-normal {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-priority-high {
    background: #ffedd5;
    color: #c2410c;
}

.badge-priority-urgent {
    background: #fee2e2;
    color: #b91c1c;
}

/* --- Gradient Text Utility --- */
.text-gradient {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-warm {
    background: linear-gradient(135deg, #f97316, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Background Gradients --- */
.bg-gradient-primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.bg-gradient-hero {
    background: linear-gradient(135deg, #172554 0%, #1e3a8a 50%, #1e40af 100%);
}

/* --- Hover Card Lift Effect --- */
.card-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(37, 99, 235, 0.15),
                0 4px 8px -2px rgba(0, 0, 0, 0.08);
}

/* --- Form Styles --- */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.form-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

.form-error {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.25rem;
}

/* --- Button Variants --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    cursor: pointer;
    outline: none;
    border: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: #16a34a;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-warning {
    background: #f97316;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #ea580c;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.btn-ghost {
    background: transparent;
    color: #2563eb;
}

.btn-ghost:hover:not(:disabled) {
    background: #eff6ff;
}

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background: #dbeafe;
    color: #2563eb;
}

.badge-success {
    background: #dcfce7;
    color: #16a34a;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-danger {
    background: #fee2e2;
    color: #ef4444;
}

.badge-info {
    background: #e0e7ff;
    color: #4338ca;
}

/* --- Table --- */
.table-container {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f9fafb;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #f3f4f6;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    color: #6b7280;
    transition: all 0.15s ease;
}

.pagination-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.pagination-btn.active {
    background: #2563eb;
    color: white;
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Mobile Bottom Nav --- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.625rem;
    color: #9ca3af;
    transition: color 0.15s ease;
    text-decoration: none;
}

.mobile-nav-item:hover {
    color: #6b7280;
}

.mobile-nav-item.active {
    color: #2563eb;
}

.mobile-nav-item.active i {
    color: #2563eb;
}

.mobile-nav-item i {
    width: 20px;
    height: 20px;
}

/* Hide mobile nav on desktop */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none;
    }
}

/* Add bottom padding for mobile nav */
@media (max-width: 767px) {
    .main-content-area {
        padding-bottom: 4.5rem;
    }
}

/* --- Active Nav Item Highlight --- */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: #f1f5f9;
    color: #334155;
}

.nav-item.active {
    color: #2563eb;
    background: #eff6ff;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #2563eb;
    border-radius: 0 3px 3px 0;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state i {
    color: #d1d5db;
    margin-bottom: 1rem;
}

/* --- Skeleton Loading --- */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

/* --- Transition Utilities --- */
.fade-enter {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fade-enter-active {
    opacity: 1;
}

/* --- Print --- */
@media print {
    .no-print {
        display: none !important;
    }
}
