/**
 * Main Styles - Hệ Thống Viết Bài Chuẩn SEO
 * Font: Be Vietnam Pro
 */

/* ========================================
   CSS Variables
======================================== */
:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-dark: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);

    /* Typography */
    --font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --navbar-height: 70px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Transitions */
    --transition: all 0.3s ease;
}

/* ========================================
   Base Styles
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    color: #1e293b;
    background-color: #f8fafc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

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

/* ========================================
   Typography
======================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: #0f172a;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   Navbar
======================================== */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.75rem 0;
    transition: var(--transition);
}

.navbar-brand {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand i {
    font-size: 1.75rem;
}

.nav-link {
    font-weight: 500;
    color: #475569 !important;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.1);
}

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* ========================================
   Buttons
======================================== */
.btn {
    font-weight: 500;
    border-radius: var(--radius);
    padding: 0.625rem 1.25rem;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    background: var(--gradient-primary);
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* ========================================
   Cards
======================================== */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    background: white;
}

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

.card-body {
    padding: 1.5rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

/* ========================================
   Forms
======================================== */
.form-control,
.form-select {
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 15px;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.input-group-text {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-right: none;
    color: #64748b;
}

.input-group .form-control {
    border-left: none;
}

.form-label {
    font-weight: 500;
    color: #334155;
    margin-bottom: 0.5rem;
}

/* ========================================
   Alerts
======================================== */
.alert {
    border: none;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

/* ========================================
   Badges
======================================== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.75em;
    border-radius: var(--radius-sm);
}

/* ========================================
   Tables
======================================== */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    padding: 1rem;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ========================================
   Main Content
======================================== */
.main-content {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* ========================================
   Footer
======================================== */
.footer {
    background: #0f172a;
    color: #94a3b8;
}

.footer h5,
.footer h6 {
    color: white;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #94a3b8;
    transition: var(--transition);
}

.footer-links a:hover {
    color: white;
}

/* ========================================
   Divider
======================================== */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #94a3b8;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e2e8f0;
}

.divider-text {
    padding: 0 1rem;
    font-size: 14px;
}

/* ========================================
   Stats Cards
======================================== */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.primary {
    background: var(--gradient-primary);
}

.stat-icon.success {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.stat-icon.warning {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.stat-icon.danger {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0;
}

.stat-content p {
    color: #64748b;
    margin-bottom: 0;
    font-size: 14px;
}

/* ========================================
   Loading Spinner
======================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   Utilities
======================================== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-gradient-primary {
    background: var(--gradient-primary);
}

.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.25rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .stat-content h3 {
        font-size: 1.5rem;
    }
}

/* ========================================
   Animations
======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* ========================================
   MOBILE RESPONSIVE - GLOBAL FIXES
======================================== */

/* Prevent horizontal overflow */
html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ========================================
   MOBILE HEADER & NAVIGATION
======================================== */
@media (max-width: 640px) {

    /* Top Bar - hide complex elements */
    .bg-gradient-to-r.from-slate-900.via-indigo-900 {
        padding: 0.5rem 0 !important;
    }

    /* Hide top bar contact info text on mobile */
    .bg-gradient-to-r.from-slate-900 .hidden.md\:block {
        display: none !important;
    }

    /* Hide the AI badge on very small screens */
    .bg-gradient-to-r.from-slate-900 .px-4.py-2.bg-gradient-to-r.from-amber-500 {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem;
    }

    .bg-gradient-to-r.from-slate-900 .px-4.py-2.bg-gradient-to-r.from-amber-500 span {
        display: none;
    }

    .bg-gradient-to-r.from-slate-900 .px-4.py-2.bg-gradient-to-r.from-amber-500 i {
        margin: 0;
    }

    /* Hide social icons on mobile */
    .hidden.sm\:flex.items-center.gap-2 {
        display: none !important;
    }

    /* Main Navigation */
    nav#mainNav .container>.flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    nav#mainNav .py-4.lg\:py-5 {
        padding: 0.75rem 0 !important;
    }

    /* Logo - smaller on mobile */
    nav#mainNav .flex.items-center.gap-4 {
        gap: 0.5rem;
    }

    nav#mainNav .w-14.h-14,
    nav#mainNav .lg\:w-16.lg\:h-16 {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }

    nav#mainNav .w-14.h-14 i,
    nav#mainNav .lg\:w-16.lg\:h-16 i {
        font-size: 1.25rem !important;
    }

    /* Logo text */
    nav#mainNav .text-2xl.lg\:text-3xl {
        font-size: 1.25rem !important;
    }

    nav#mainNav span.block.text-sm {
        display: none !important;
    }

    /* Right actions - tighten spacing */
    nav#mainNav .flex.items-center.gap-3.lg\:gap-4 {
        gap: 0.375rem !important;
    }

    /* Hide Write Now CTA on mobile */
    nav#mainNav .hidden.md\:flex.items-center.gap-2.px-6.py-3 {
        display: none !important;
    }

    /* Dark mode toggle - smaller */
    nav#mainNav .w-12.h-12.rounded-xl {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }

    /* Hide login button text, keep icon */
    nav#mainNav a.hidden.sm\:flex.items-center.gap-2.px-5.py-3 {
        display: none !important;
    }

    /* Register button - compact */
    nav#mainNav a.flex.items-center.gap-2.px-6.py-3.bg-gradient-to-r {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
        gap: 0 !important;
    }

    nav#mainNav a.flex.items-center.gap-2.px-6.py-3.bg-gradient-to-r i {
        display: none;
    }

    /* Credits display - smaller */
    nav#mainNav a.hidden.sm\:flex.items-center.gap-2.px-5.py-3.bg-gradient-to-r.from-amber-400 {
        display: none !important;
    }

    /* User dropdown button */
    nav#mainNav .flex.items-center.gap-3.px-3.py-2 {
        padding: 0.25rem !important;
        gap: 0 !important;
    }

    nav#mainNav .flex.items-center.gap-3.px-3.py-2 .w-12.h-12 {
        width: 36px !important;
        height: 36px !important;
    }

    nav#mainNav .flex.items-center.gap-3.px-3.py-2 .hidden.lg\:block {
        display: none !important;
    }

    /* Mobile menu */
    .mobile-nav-item {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
}

/* Very small screens */
@media (max-width: 375px) {

    /* Even more compact header */
    nav#mainNav .w-14.h-14,
    nav#mainNav .lg\:w-16.lg\:h-16 {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    nav#mainNav .text-2xl.lg\:text-3xl {
        font-size: 1.1rem !important;
    }

    nav#mainNav .w-12.h-12.rounded-xl {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    nav#mainNav a.flex.items-center.gap-2.px-6.py-3.bg-gradient-to-r {
        padding: 0.375rem 0.625rem !important;
        font-size: 0.75rem !important;
    }
}

/* ========================================
   MOBILE HERO SECTION FIXES
======================================== */
@media (max-width: 640px) {

    /* Hero flex direction */
    .hero-wrapper .flex.flex-col.lg\:flex-row {
        flex-direction: column !important;
    }

    /* Hero text area - full width */
    .hero-wrapper .lg\:w-1\/2 {
        width: 100% !important;
    }

    /* Badge - smaller */
    .hero-wrapper .inline-flex.items-center.gap-2.px-4.py-2 {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    /* Hero buttons - STACK vertically */
    .hero-wrapper .flex.flex-wrap.gap-4 {
        flex-direction: column !important;
        width: 100% !important;
    }

    .hero-wrapper .flex.flex-wrap.gap-4>a {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
        padding: 0.875rem 1rem !important;
        font-size: 0.95rem !important;
    }

    /* Provider logos - wrap */
    .hero-wrapper .flex.flex-wrap.gap-6 {
        gap: 0.75rem !important;
    }

    .hero-wrapper .provider-logo {
        height: 20px !important;
    }

    /* Code preview card */
    .hero-wrapper .glass-card.max-w-lg {
        max-width: 100% !important;
        margin: 1rem 0 0 0 !important;
    }

    /* Hide decorative elements */
    .hero-wrapper .absolute {
        display: none !important;
    }
}

/* ========================================
   MOBILE GRID FIXES
======================================== */
@media (max-width: 640px) {

    /* Force single column on mobile for card grids */
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4,
    .grid.grid-cols-1.md\:grid-cols-3,
    .grid.grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* 2 columns for stats */
    .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* 3 columns for integrations */
    .grid.grid-cols-2.md\:grid-cols-3.lg\:grid-cols-6 {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem !important;
    }
}

/* ========================================
   MOBILE FOOTER FIXES
======================================== */
@media (max-width: 640px) {
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    footer .text-center.md\:text-left {
        text-align: center !important;
    }

    footer .flex.justify-between {
        flex-direction: column !important;
        gap: 1rem !important;
        text-align: center !important;
    }
}

/* ========================================
   MOBILE DROPDOWN FIXES
======================================== */
@media (max-width: 768px) {

    /* User menu dropdown - full width on mobile */
    #userMenu .min-w-\[480px\] {
        min-width: calc(100vw - 2rem) !important;
        max-width: calc(100vw - 2rem) !important;
        right: -1rem !important;
    }

    #userMenu .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* Language dropdown */
    #langMenu {
        right: 0 !important;
    }
}

/* ========================================
   MOBILE FEATURES SECTION FIXES
======================================== */
@media (max-width: 768px) {

    /* Feature images - hide skew */
    section img.skew-y-2,
    section img.skew-x-1,
    section .skew-y-2,
    section .skew-x-1 {
        transform: none !important;
    }

    /* Feature section flex */
    section .flex.flex-col.lg\:flex-row {
        flex-direction: column !important;
    }

    section .flex.flex-col.lg\:flex-row>div {
        width: 100% !important;
        order: unset !important;
    }

    /* Feature image containers */
    section .lg\:w-1\/2 {
        width: 100% !important;
    }
}

/* ========================================
   CRITICAL: PREVENT ALL HORIZONTAL OVERFLOW
======================================== */
* {
    max-width: 100%;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative;
}

/* Force all containers to respect viewport */
.container {
    max-width: 100% !important;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* All grids should not overflow */
    .grid {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* All flex containers */
    .flex {
        max-width: 100%;
    }

    /* Stat cards in footer - fix number overflow */
    .statistics-section .stat-number,
    footer .text-3xl,
    footer .md\:text-4xl {
        font-size: 1.5rem !important;
        word-break: break-word;
    }

    /* Stats bar in footer - compact padding */
    footer .grid.grid-cols-2 .p-6 {
        padding: 0.75rem !important;
    }

    footer .grid.grid-cols-2 .text-3xl,
    footer .grid.grid-cols-2 .md\:text-4xl {
        font-size: 1.25rem !important;
    }

    footer .grid.grid-cols-2 .text-sm {
        font-size: 0.7rem !important;
    }

    /* Newsletter form in footer */
    footer form.flex {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    footer form input {
        width: 100% !important;
    }

    footer form button {
        width: 100% !important;
    }
}

/* ========================================
   STATS SECTION MOBILE FIX
======================================== */
@media (max-width: 640px) {

    /* Homepage stats section */
    .statistics-section .grid {
        gap: 0.5rem !important;
    }

    .statistics-section .stat-card {
        padding: 0.75rem !important;
    }

    .statistics-section .stat-number {
        font-size: 1.25rem !important;
    }

    .statistics-section .stat-card p {
        font-size: 0.7rem !important;
    }

    /* Footer stats bar */
    footer .mb-12 .grid {
        gap: 0.5rem !important;
    }

    footer .mb-12 .p-6 {
        padding: 0.75rem !important;
        border-radius: 1rem !important;
    }

    footer .mb-12 .text-3xl {
        font-size: 1.125rem !important;
    }

    footer .mb-12 .text-sm {
        font-size: 0.65rem !important;
        margin-top: 0.125rem !important;
    }
}

/* ========================================
   SECURITY BADGES MOBILE
======================================== */
@media (max-width: 640px) {
    .security-badge {
        padding: 0.625rem 0.75rem !important;
        gap: 0.5rem !important;
    }

    .security-badge .w-12 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem !important;
    }

    .security-badge h4 {
        font-size: 0.75rem !important;
    }

    .security-badge p {
        font-size: 0.65rem !important;
    }

    /* Wrap badges on small screens */
    .flex.flex-wrap.justify-center.gap-8 {
        gap: 0.5rem !important;
    }
}

/* ========================================
   FINAL OVERFLOW PREVENTION
======================================== */
@media (max-width: 768px) {

    /* Hide any absolute positioned decorative elements */
    .absolute {
        max-width: 100vw !important;
    }

    /* Main content area */
    main.main-content {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Footer */
    footer {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* All sections */
    section {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Nav */
    nav {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Top bar */
    #topBar {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
}