/* ============================================================
   BASE.CSS - Nền tảng, biến, reset, typography
   ============================================================ */

/* CSS Variables */
:root {
    /* Colors */
    --mau-chinh: #0768f0;
    --mau-phu: #8b4513;
    --mau-thanh-cong: #10b981;
    --mau-canh-bao: #f59e0b;
    --mau-loi: #ef4444;
    
    --mau-chu-chinh: #1f2937;
    --mau-chu-phu: #6b7280;
    --mau-chu-nhe: #9ca3af;
    
    --mau-nen: #ffffff;
    --mau-nen-xam: #f3f4f6;
    --mau-vien: #e5e7eb;
    
    /* Spacing */
    --khoang-cach-xs: 0.25rem;   /* 4px */
    --khoang-cach-sm: 0.5rem;    /* 8px */
    --khoang-cach-md: 1rem;      /* 16px */
    --khoang-cach-lg: 1.5rem;    /* 24px */
    --khoang-cach-xl: 2rem;      /* 32px */
    --khoang-cach-2xl: 3rem;     /* 48px */
    
    /* Typography - TĂNG 0.2rem */
    --font-chu: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-xs: 0.95rem;     
    --font-size-sm: 1.075rem;    
    --font-size-base: 1.2rem;    
    --font-size-lg: 1.325rem;    
    --font-size-xl: 1.45rem;     
    --font-size-2xl: 1.7rem;     
    --font-size-3xl: 2.075rem;   
    
    /* Border Radius */
    --bo-goc-sm: 0.25rem;
    --bo-goc-md: 0.5rem;
    --bo-goc-lg: 0.75rem;
    --bo-goc-full: 9999px;
    
    /* Shadows */
    --bong-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --bong-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --bong-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --bong-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    
    /* Transitions */
    --chuyen-canh-nhanh: 150ms ease-in-out;
    --chuyen-canh-trung-binh: 300ms ease-in-out;
    --chuyen-canh-cham: 500ms ease-in-out;
    
    /* Breakpoints (for JS) */
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    
    /* Safe Areas cho iPhone notch */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* ============================================================
   RESET CSS
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-chu);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--mau-chu-chinh);
    background-color: var(--mau-nen);
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

/* Touch Optimizations */
a, button, input, select, textarea, [role="button"] {
    /* Tắt highlight màu xanh khi tap trên mobile */
    -webkit-tap-highlight-color: transparent;
    /* Tối ưu touch */
    touch-action: manipulation;
}

/* Tắt zoom khi double tap trên input (iOS) */
input, select, textarea {
    font-size: max(var(--font-size-base), 16px);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    /* Prevent image dragging */
    -webkit-user-drag: none;
    user-select: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

ul, ol {
    list-style: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--mau-chinh);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Selection color */
::selection {
    background-color: var(--mau-chinh);
    color: white;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* Display */
.an { display: none !important; }
.hien { display: block !important; }
.hien-flex { display: flex !important; }
.hien-grid { display: grid !important; }

/* Text Alignment */
.chu-trai { text-align: left; }
.chu-giua { text-align: center; }
.chu-phai { text-align: right; }

/* Font Weight */
.chu-nhe { font-weight: 300; }
.chu-binh-thuong { font-weight: 400; }
.chu-dam { font-weight: 600; }
.chu-rat-dam { font-weight: 700; }

/* Colors */
.chu-chinh { color: var(--mau-chinh); }
.chu-phu { color: var(--mau-chu-phu); }
.chu-nhe { color: var(--mau-chu-nhe); }
.chu-trang { color: white; }

/* Spacing */
.mt-sm { margin-top: var(--khoang-cach-sm); }
.mt-md { margin-top: var(--khoang-cach-md); }
.mt-lg { margin-top: var(--khoang-cach-lg); }
.mb-sm { margin-bottom: var(--khoang-cach-sm); }
.mb-md { margin-bottom: var(--khoang-cach-md); }
.mb-lg { margin-bottom: var(--khoang-cach-lg); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--khoang-cach-md);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
    margin-bottom: var(--khoang-cach-md);
}

/* ============================================================
   RESPONSIVE TEXT
   ============================================================ */

@media (max-width: 768px) {
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
}

/* ============================================================
   MOBILE SPECIFIC STYLES
   ============================================================ */

/* Prevent text selection on UI elements */
.no-select {
    -webkit-user-select: none;
    user-select: none;
}

/* Active state for touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .card:active,
    .nav__link:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Increase touch targets on mobile */
@media (max-width: 768px) {
    .btn, 
    .btn-icon,
    .nav__link,
    .dropdown__item {
        min-height: 44px; /* Apple's minimum touch target */
        min-width: 44px;
    }
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */

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

::-webkit-scrollbar-track {
    background: var(--mau-nen-xam);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--mau-vien);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mau-chu-phu);
}

/* Hide scrollbar on mobile but keep functionality */
@media (max-width: 768px) {
    .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .hide-scrollbar::-webkit-scrollbar {
        display: none;
    }
}

/* ============================================================
   LANDSCAPE MODE ADJUSTMENTS
   ============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --font-size-base: 1rem;
        --font-size-lg: 1.125rem;
        --font-size-xl: 1.25rem;
        --khoang-cach-md: 0.75rem;
        --khoang-cach-lg: 1rem;
    }
}