:root {
    --brand-primary: #a855f7;
    --brand-primary-dark: #7c3aed;
    --brand-glow-1: rgba(139, 92, 246, 0.15);
    --brand-glow-2: rgba(59, 130, 246, 0.15);
    --brand-glow-3: rgba(217, 70, 239, 0.15);
    --brand-bg-tint: rgba(88, 28, 135, 0.85);
    --bg-dark: #0d1117;
    --bg-medium: #161b22;
    --bg-light: #21262d;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
}

body {
    font-family: 'Sarabun', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    /* Allow each page to manage its own vertical scrolling while
       preventing horizontal overflow from the animated background */
    overflow-x: hidden;
    overflow-y: auto;
}

.main-container {
    position: relative;
    z-index: 1;
    height: 100vh;
    overflow-y: auto;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(ellipse at 20% 80%, var(--brand-glow-1), transparent 70%),
        radial-gradient(ellipse at 80% 30%, var(--brand-glow-2), transparent 70%),
        radial-gradient(ellipse at 90% 90%, var(--brand-glow-3), transparent 70%);
    animation: move-glow 25s linear infinite;
    z-index: 0;
}

@keyframes move-glow {
    0% {
        background-position: 0% 50%, 50% 0%, 90% 90%;
    }

    50% {
        background-position: 100% 50%, 50% 100%, 0% 0%;
    }

    100% {
        background-position: 0% 50%, 50% 0%, 90% 90%;
    }
}


.font-display {
    font-family: 'Playfair Display', serif;
}

.brand-accent {
    color: var(--brand-primary);
}

.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--brand-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(167, 139, 250, 0.1);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
}

.btn-secondary {
    background-color: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: #dc2626;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-danger:hover:not(:disabled) {
    background-color: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.1);
}

.btn-danger:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.btn:hover::after {
    left: 150%;
}

.form-input,
.form-select,
.form-textarea {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow-1), 0 0 15px var(--brand-glow-1) inset;
}

.form-input:disabled {
    background-color: var(--bg-medium);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-display {
    background-color: var(--bg-medium);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    width: 100%;
    min-height: 46px;
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portal-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 0.75rem;
    background-color: var(--bg-medium);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    text-align: center;
    position: relative;
}

.portal-menu-item:hover {
    background-color: var(--bg-light);
    color: white;
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: var(--brand-primary);
}

.portal-menu-item.active {
    background-color: #3b0764;
    border-color: var(--brand-primary);
    color: white;
}

.notification-dot {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 0.75rem;
    height: 0.75rem;
    background-color: #f85149;
    border-radius: 9999px;
    border: 2px solid var(--bg-medium);
}

.notification-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    background-color: #f85149;
    border-radius: 9999px;
    border: 2px solid var(--bg-medium);
    color: white;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(5px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 50;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    background-color: var(--bg-medium);
    border: 1px solid var(--border-color);
}

.modal-content.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    z-index: 100;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
}

.toast-success {
    background-color: #238636;
    border-color: #2ea043;
}

.toast-error {
    background-color: #da3633;
    border-color: #f85149;
}

.glass-pane {
    background-color: rgba(22, 27, 34, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

.loading-spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

#portal-content-area {
    margin-top: 12px;
}

/* Portal menu size adjustments */
.portal-menu-item {
    min-height: 100px !important;
    padding: 0.75rem !important;
}

.portal-menu-item div:first-child {
    font-size: 1.75rem !important;
    margin-bottom: 0.375rem !important;
}

.portal-menu-item div:last-child {
    font-size: 0.8rem !important;
}

#portal-content-area {
    margin-top: 12px;
}

#portal-content-area {
    margin-top: 12px;
}

.nav-btn {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    color: #ffffff;
    opacity: 0.7;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    position: relative;
}

.nav-btn:hover {
    opacity: 1;
    border-bottom-color: var(--brand-primary, #a855f7);
}

.nav-btn-active {
    opacity: 1;
    border-bottom-color: var(--brand-primary, #a855f7);
    color: #ffffff;
}

.file-viewer-panel {
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96) 0%, rgba(30, 41, 59, 0.95) 60%, rgba(88, 28, 135, 0.85) 100%);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.file-viewer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.file-viewer-close {
    font-size: 1.75rem;
    line-height: 1;
    color: rgba(226, 232, 240, 0.8);
    transition: color 0.2s ease, transform 0.2s ease;
}

.file-viewer-close:hover {
    color: #ffffff;
    transform: scale(1.05);
}

.file-viewer-body {
    padding: 1.5rem;
    padding-bottom: 0;
}

.file-viewer-stage {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 1rem;
    padding: 1rem;
    min-height: 50vh;
    max-height: 70vh;
    display: flex;
}

#file-viewer-scroll {
    min-height: 45vh;
    max-height: 100%;
}

.file-viewer-scroll {
    background: rgba(2, 6, 23, 0.55);
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.1);
    padding: 0.75rem;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

#file-viewer-image.file-viewer-fit {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
}

#file-viewer-image.file-viewer-original {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
}

.file-viewer-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.65);
}

.viewer-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.viewer-nav-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.viewer-nav-btn:hover {
    background: rgba(88, 28, 135, 0.85);
    border-color: var(--brand-primary);
}

.viewer-nav-btn:disabled,
.viewer-nav-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(148, 163, 184, 0.15);
}

.viewer-nav-label {
    min-width: 3rem;
    text-align: center;
    font-size: 0.875rem;
    color: rgba(226, 232, 240, 0.75);
}

.viewer-action-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.viewer-mode-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#file-viewer-controls .active {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
    box-shadow: 0 10px 25px rgba(88, 28, 135, 0.35);
}

/* Dashboard Improvements */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-card {
    animation: slideInUp 0.5s ease-out;
}

.dashboard-card:nth-child(1) {
    animation-delay: 0.1s;
}

.dashboard-card:nth-child(2) {
    animation-delay: 0.2s;
}

.dashboard-card:nth-child(3) {
    animation-delay: 0.3s;
}

.dashboard-card:nth-child(4) {
    animation-delay: 0.4s;
}

.dashboard-card:nth-child(5) {
    animation-delay: 0.5s;
}

.dashboard-card:nth-child(6) {
    animation-delay: 0.6s;
}

/* Improved card hover effects */
.glass-pane {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Only apply hover effect if card doesn't have specific hover styles */
.glass-pane:not([data-shipment-card]):not(.no-hover):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Enhanced focus states */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}


/* Gradient text effect */
.gradient-text {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Header navigation tabs */
#header-nav-tabs {
    min-width: 0;
}

#header-nav-tabs .home-tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* User menu dropdown */
#user-menu-dropdown {
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#user-menu-dropdown button {
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

#user-menu-dropdown button:last-child {
    border-bottom: none;
}

/* Responsive header adjustments */
@media (max-width: 640px) {
    #header-nav-tabs {
        max-width: calc(100vw - 140px);
    }

    #header-user-name {
        display: none !important;
    }
}

/* ============================================ */
/* NEW HOME PAGE ANIMATIONS & STYLES */
/* ============================================ */

/* Shimmer animation effects */
@keyframes shimmer-slow {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes shimmer-fast {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.animate-shimmer-slow {
    background-size: 200% 100%;
    animation: shimmer-slow 8s linear infinite;
}

.animate-shimmer-fast {
    animation: shimmer-fast 2s linear infinite;
}

/* Pulse animation with delay */
@keyframes pulse-slow {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.animate-pulse-slow {
    animation: pulse-slow 4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animation-delay-1000 {
    animation-delay: 1s;
}

/* Slide up animation */
@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slide-up 0.8s ease-out;
}

.animation-delay-100 {
    animation-delay: 0.1s;
    opacity: 0;
    animation-fill-mode: forwards;
}

.animation-delay-200 {
    animation-delay: 0.2s;
    opacity: 0;
    animation-fill-mode: forwards;
}

.animation-delay-300 {
    animation-delay: 0.3s;
    opacity: 0;
    animation-fill-mode: forwards;
}

/* Float animation for hero icon */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Gradient text for hero */
.gradient-text-hero {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 50%, var(--brand-primary) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% center;
    }

    50% {
        background-position: 100% center;
    }
}

/* Dashboard card improvements */
.dashboard-card {
    opacity: 0;
    animation: slideInUp 0.6s ease-out forwards;
}

/* Premium hover effect for cards */
.dashboard-card:hover {
    transform: translateY(-4px) scale(1.01);
}

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

button,
a,
input,
select,
textarea {
    transition-duration: 200ms;
}

/* Prevent transition on page load */
.preload * {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}

/* Modern Navigation Pills */
.nav-pill {
    cursor: pointer;
    user-select: none;
}

.nav-pill.active .absolute.inset-0:first-child {
    background-color: rgba(51, 65, 85, 0.8);
}

.nav-pill:not(.active):hover {
    transform: translateY(-1px);
}

.nav-pill.active {
    transform: translateY(0);
}