/* 
  ICTU Quizzes - Mobile Optimization CSS
  Tối ưu hóa cho thiết bị di động và cải thiện trải nghiệm người dùng
*/


/* Responsive font sizes */

html {
    font-size: 16px;
}

@media (max-width: 640px) {
    html {
        font-size: 14px;
    }
}


/* Hiệu ứng ripple cho nút (trên mobile) */

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple:after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform .5s, opacity 1s;
}

.btn-ripple:active:after {
    transform: scale(0, 0);
    opacity: .3;
    transition: 0s;
}


/* Ẩn scrollbar nhưng vẫn cho phép scroll */

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}


/* Tối ưu input trên thiết bị di động */

@media (max-width: 640px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Ngăn iOS tự động zoom khi focus */
    }
}


/* Card hover animations */

.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.dark .card-hover:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}


/* Skeleton loading animation */

.skeleton {
    position: relative;
    overflow: hidden;
    background-color: #e2e8f0;
}

.dark .skeleton {
    background-color: #374151;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 20%, rgba(255, 255, 255, 0.5) 60%, rgba(255, 255, 255, 0) 100%);
    animation: shimmer 2s infinite;
}

.dark .skeleton::after {
    background: linear-gradient(90deg, rgba(42, 48, 60, 0) 0%, rgba(42, 48, 60, 0.2) 20%, rgba(42, 48, 60, 0.5) 60%, rgba(42, 48, 60, 0) 100%);
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}


/* Text overflow ellipsis */

.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* Pull-to-refresh indicator */

.refresh-indicator {
    height: 50px;
    margin-top: -50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: margin-top 0.3s ease;
}

.refreshing .refresh-indicator {
    margin-top: 0;
}


/* Toast notifications */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem;
    border-radius: 0.5rem;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 50;
    max-width: 18rem;
}

@media (min-width: 640px) {
    .toast {
        max-width: 24rem;
    }
}

.toast.show {
    transform: translateX(0);
}

.dark .toast {
    background: #1e293b;
    color: white;
}


/* Mobile menu */

.mobile-menu {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}

.mobile-menu.open {
    transform: translateX(0);
}


/* Custom scrollbar */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dark ::-webkit-scrollbar-track {
    background: #1f2937;
}

::-webkit-scrollbar-thumb {
    background: #c7d2fe;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4f46e5;
}

::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}


/* Floating action button (mobile) */

@media (max-width: 768px) {
    .fab {
        position: fixed;
        bottom: 1.5rem;
        right: 1.5rem;
        height: 3.5rem;
        width: 3.5rem;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
        z-index: 40;
    }
    .fab-icon {
        font-size: 1.5rem;
        color: white;
    }
}


/* Tab active states */

.tab-active {
    border-bottom: 2px solid #4f46e5;
    color: #4f46e5;
}

.dark .tab-active {
    border-bottom: 2px solid #818cf8;
    color: #818cf8;
}


/* Improve focus states for keyboard navigation */

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.dark button:focus-visible,
.dark a:focus-visible,
.dark input:focus-visible,
.dark select:focus-visible,
.dark textarea:focus-visible {
    outline: 2px solid #818cf8;
}


/* Improved form elements */

input,
select,
textarea {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.dark input:focus,
.dark select:focus,
.dark textarea:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}


/* CSS hỗ trợ hình ảnh hiển thị tốt hơn */

img {
    max-width: 100%;
    height: auto;
}


/* Safe area insets for mobile devices with notches */

@supports (padding: max(0px)) {
    .has-safe-area {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}