body {
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    -ms-overflow-style: none;
    /* Smooth transition cho dark mode */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode transitions */
html {
    scroll-behavior: smooth;
    scrollbar-width: none;
    transition: background-color 0.3s ease;
}

.gradient-text {
    background: linear-gradient(to right, #4f46e5, #818cf8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}


.hidden-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
}

.visible {
    opacity: 1;
    transform: translateY(0);
}

/* TinyMCE Dark Mode Improvements - handled in editor.php */

/* Theme toggle button styles */
#theme-toggle {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

#theme-toggle:hover {
    transform: scale(1.1);
}

#theme-toggle svg {
    transition: transform 0.3s ease;
}

#theme-toggle:active svg {
    transform: scale(0.9);
}

/* Improved form controls for dark mode */
.dark input[type="text"],
.dark input[type="password"],
.dark input[type="email"],
.dark textarea,
.dark select {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f3f4f6 !important;
    transition: all 0.3s ease;
}

.dark input[type="text"]:focus,
.dark input[type="password"]:focus,
.dark input[type="email"]:focus,
.dark textarea:focus,
.dark select:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

.dark input[type="text"]::placeholder,
.dark input[type="password"]::placeholder,
.dark input[type="email"]::placeholder,
.dark textarea::placeholder {
    color: #9ca3af !important;
}

/* Dark mode button improvements */
.dark button:not(.bg-indigo-600):not(.bg-red-600):not(.bg-green-600) {
    background-color: #4b5563;
    color: #f3f4f6;
    border-color: #6b7280;
}

.dark button:not(.bg-indigo-600):not(.bg-red-600):not(.bg-green-600):hover {
    background-color: #374151;
}

/* Modal and dropdown improvements for dark mode */
.dark .modal,
.dark .dropdown-menu {
    background-color: #1f2937 !important;
    border-color: #4b5563 !important;
    color: #f3f4f6 !important;
}

/* Link improvements for dark mode */
.dark a:not(.btn):not(.button) {
    color: #60a5fa;
}

.dark a:not(.btn):not(.button):hover {
    color: #93c5fd;
}

/* Card and panel improvements for dark mode */
.dark .bg-white {
    background-color: #1f2937 !important;
}

.dark .bg-gray-50 {
    background-color: #111827 !important;
}

.dark .bg-gray-100 {
    background-color: #374151 !important;
}

.dark .border-gray-200,
.dark .border-gray-300 {
    border-color: #4b5563 !important;
}

/* Text color improvements */
.dark .text-gray-600 {
    color: #d1d5db !important;
}

.dark .text-gray-700 {
    color: #f3f4f6 !important;
}

.dark .text-gray-800 {
    color: #f9fafb !important;
}

.dark .text-gray-900 {
    color: #ffffff !important;
}

/* Shadow improvements for dark mode */
.dark .shadow,
.dark .shadow-sm,
.dark .shadow-md,
.dark .shadow-lg {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}

/* Loading and skeleton improvements */
.dark .animate-pulse {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dark {
        --tw-bg-opacity: 1;
        background-color: #000000;
        color: #ffffff;
    }
    
    .dark .border {
        border-color: #ffffff !important;
    }
}

/* Popup Advertisement Styles */
#popup-ad-overlay {
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#popup-ad-overlay > div {
    animation: slideIn 0.3s ease-out;
    transform: translateY(0);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Popup responsive */
@media (max-width: 480px) {
    #popup-ad-overlay > div {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}

/* Popup button hover effects */
#popup-ad-overlay button {
    transition: all 0.2s ease;
}

#popup-ad-overlay button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#popup-ad-overlay button:active {
    transform: translateY(0);
}

/* Dark mode popup improvements */
.dark #popup-ad-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

.dark #popup-ad-overlay > div {
    border: 1px solid #374151;
}

/* Accessibility improvements */
#popup-ad-overlay:focus {
    outline: none;
}

#popup-ad-overlay button:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Loading state for buttons */
.popup-button-loading {
    position: relative;
    color: transparent !important;
}

.popup-button-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Debug styles for popup advertisement form */
#popup_ad_url_container {
    transition: all 0.3s ease;
    overflow: hidden;
}

#popup_ad_url_container.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#popup_ad_url_container:not(.hidden) {
    max-height: 200px;
    opacity: 1;
}

/* Ensure checkbox and form elements are visible */
input[type="checkbox"], input[type="url"] {
    visibility: visible !important;
    display: block !important;
}

/* Debug border for development */
.debug-border {
    border: 2px solid red !important;
}

/* Modal styles */
#confirmationModal {
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

#confirmationModal .bg-white {
    animation: scaleIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Hover effects for buttons */
.open-modal:hover {
    text-decoration: underline;
    cursor: pointer;
}

/* Focus styles for accessibility */
#modalCancelButton:focus,
#modalConfirmButton:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* Processing modal animation */
#processingModal {
    backdrop-filter: blur(6px);
}

/* Avatar hover effect */
.rounded-full:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* TinyMCE Table Styles */
.table-simple {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.table-simple th,
.table-simple td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.dark .table-simple th,
.dark .table-simple td {
    border-bottom-color: #4b5563;
}

.table-bordered {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    border: 1px solid #e5e7eb;
}

.table-bordered th,
.table-bordered td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.dark .table-bordered {
    border-color: #4b5563;
}

.dark .table-bordered th,
.dark .table-bordered td {
    border-color: #4b5563;
}

.table-striped {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.table-striped th,
.table-striped td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table-striped tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.dark .table-striped th,
.dark .table-striped td {
    border-bottom-color: #4b5563;
}

.dark .table-striped tbody tr:nth-child(even) {
    background-color: #374151;
}

.table-striped th {
    background-color: #f3f4f6;
    font-weight: 600;
}

.dark .table-striped th {
    background-color: #4b5563;
}

/* Font size variations for content */
.content-area {
    line-height: 1.6;
}

.content-area h1 { font-size: 2.25rem; line-height: 2.5rem; }
.content-area h2 { font-size: 1.875rem; line-height: 2.25rem; }
.content-area h3 { font-size: 1.5rem; line-height: 2rem; }
.content-area h4 { font-size: 1.25rem; line-height: 1.75rem; }
.content-area h5 { font-size: 1.125rem; line-height: 1.75rem; }
.content-area h6 { font-size: 1rem; line-height: 1.5rem; }

.content-area p { margin: 1em 0; }
.content-area blockquote {
    margin: 1.5em 0;
    padding: 1em;
    border-left: 4px solid #6366f1;
    background-color: #f8fafc;
    color: #4b5563;
    font-style: italic;
}

.dark .content-area blockquote {
    background-color: #374151;
    color: #d1d5db;
}

.content-area code {
    background-color: #f3f4f6;
    color: #dc2626;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.dark .content-area code {
    background-color: #374151;
    color: #fbbf24;
}

.content-area pre {
    background-color: #1f2937;
    color: #f3f4f6;
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
}

.content-area pre code {
    background: none;
    color: inherit;
    padding: 0;
}

/* Text formatting from TinyMCE */
.content-area strong { font-weight: 700; }
.content-area em { font-style: italic; }
.content-area u { text-decoration: underline; }
.content-area s { text-decoration: line-through; }

/* Lists */
.content-area ul, .content-area ol {
    margin: 1em 0;
    padding-left: 2em;
}

.content-area ul li {
    list-style-type: disc;
    margin: 0.5em 0;
}

.content-area ol li {
    list-style-type: decimal;
    margin: 0.5em 0;
}

/* Links */
.content-area a {
    color: #2563eb;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.content-area a:hover {
    color: #1d4ed8;
}

.dark .content-area a {
    color: #60a5fa;
}

.dark .content-area a:hover {
    color: #93c5fd;
}