/* public_html/public/css/global.css - PHIÊN BẢN V1.0: STYLE DÙNG CHUNG */

/* ==========================================================================
   1. VARIABLES & BASE SETTINGS
   ========================================================================== */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;

    --color-bg-light: #f8fafc;
    --color-text-dark: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-sidebar: #ffffff;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --sidebar-width-collapsed: 5rem;
    --sidebar-width-expanded: 17rem;
    --transition-speed: 0.3s;
    --header-height: 4rem;
}

/* Khóa cuộn ngang tuyệt đối & Fix PWA Android Pull-to-refresh */
html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    height: 100%;
    overscroll-behavior-y: none;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    overscroll-behavior-y: none;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 0.875rem;
    line-height: 1.5;
}

.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* ==========================================================================
   2. SKELETON LOADING
   ========================================================================== */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    display: inline-block;
    width: 100%;
}

html.dark .skeleton {
    background: #1e293b;
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 0.75rem;
    margin-bottom: 0.5rem;
    width: 80%;
}

.skeleton-title {
    height: 1.25rem;
    margin-bottom: 1rem;
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: 12px;
}

.skeleton-table-row {
    height: 48px;
    margin-bottom: 8px;
}

/* ==========================================================================
   3. DARK MODE (BASE SETTINGS)
   ========================================================================== */
html.dark {
    --color-bg-light: #0f172a;
    --color-text-dark: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --color-sidebar: #1e293b;
}

html.dark body {
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
}

/* ==========================================================================
   4. UI UTILITIES & COMPONENTS
   ========================================================================== */
.card-modern {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

html.dark .card-modern {
    background-color: #1e293b;
    border-color: #334155;
}

.kpi-value {
    font-family: var(--font-sans);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

@media (max-width: 768px) {
    .modal {
        padding-bottom: 80px !important;
    }
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

html.dark .modal-content {
    background-color: #1e293b;
    border: 1px solid #334155;
}

/* Form Elements */
.input-field,
select,
textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: white;
    transition: all 0.2s;
}

.input-field:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

html.dark .input-field,
html.dark select,
html.dark textarea {
    background-color: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

.hidden {
    display: none !important;
}

/* Scrollbar & PWA Touch Scroll Fix */
.overflow-y-auto,
.custom-scrollbar {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

html.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569;
}

/* Dropdown */
#notification-dropdown {
    right: -10px;
    top: 3.5rem;
    width: 360px;
    max-width: 90vw;
    transform-origin: top right;
    animation: dropdownFadeIn 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* ==========================================================================
   5. ANIMATIONS & CUSTOM UTILITIES
   ========================================================================== */
@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes bell-shake {
    0% {
        transform: rotate(0);
    }

    15% {
        transform: rotate(5deg);
    }

    30% {
        transform: rotate(-5deg);
    }

    45% {
        transform: rotate(4deg);
    }

    60% {
        transform: rotate(-4deg);
    }

    75% {
        transform: rotate(2deg);
    }

    85% {
        transform: rotate(-2deg);
    }

    100% {
        transform: rotate(0);
    }
}

.animate-bell-shake {
    animation: bell-shake 2s infinite;
    transform-origin: top center;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes toast-progress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.animate-fade-in-right {
    animation: fadeInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-out-right {
    animation: fadeOutRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-out-down {
    animation: fadeOutDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none !important;
}

.hide-scrollbar {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

.scale-up {
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal:not(.hidden) .scale-up,
.modal:not(.hidden) .modal-content {
    transform: scale(1);
    opacity: 1;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.kpi-active {
    box-shadow: 0 0 0 2px var(--color-primary), 0 4px 6px -1px rgb(0 0 0 / 0.1);
    transform: translateY(-2px);
}

html.dark .kpi-active {
    box-shadow: 0 0 0 2px #818cf8, 0 4px 6px -1px rgb(0 0 0 / 0.3);
}