/* ============================================
   HOME PAGE - MINIMAL LAYOUT
   ============================================ */

/* Font Family */
body {
    font-family: 'Be Vietnam Pro', 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Be Vietnam Pro', 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   ANIMATIONS & KEYFRAMES
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* App wrapper - Full page layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* animation: fadeIn 0.6s ease-out; */
}

/* Main content grows to fill available space */
.main-content {
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 70px;
    margin-bottom: 100px;
}

/* Khi search page - main-content adjust cho fixed search bar */
.search-page-bar ~ .main-content {
    margin-top: 140px;
}

/* Khi livesearch show ở home page - co lại khoảng cách */
#liveSearchResults.show ~ .main-content {
    margin-top: 20px;
}

/* Khi livesearch show - hero collapse */
.hero:has(+ * #liveSearchResults.show) {
    padding: 20px;
    min-height: auto;
}

/* Content container - Centered search only */
.content-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    animation: fadeIn 0.6s ease-out 0.3s both;
}

/* Navbar container */
.navbar-container {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

/* Hero section - Centered */
.hero {
    padding: 100px;
    text-align: center;
    border-bottom: 1px solid var(--border-primary);
    position: relative;
    overflow: hidden;
    animation: slideDown 0.8s ease-out;
    transition: opacity 0.5s ease, visibility 0.5s ease, padding 0.3s ease;
}

/* Co lại hero khi livesearch active */
.hero.livesearch-active {
    padding: 20px;
    min-height: auto;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    pointer-events: none;
}

.hero-content {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #ff8a9b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    line-height: 1.2;
    padding: 10px;
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    padding: 10px 20px;
    text-align: center;
    color: var(--text-secondary);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
}

.footer-content {
    max-width: 100%;
    margin: 0 auto;
}

.footer p {
    margin: 0;
}

/* Search section - Centered and minimal */
.search-section {
    position: relative;
    z-index: 100;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-primary);
    max-width: 850px;
    margin: 0 auto;
    animation: scaleIn 0.6s ease-out 0.2s both;
    transition: margin 0.3s ease, padding 0.3s ease;
}

/* Gần hero hơn khi livesearch active */
.search-section.livesearch-active {
    margin-top: -40px;
    padding: 20px;
}

/* Search bar trên trang search - fixed top */
.search-page-bar {
    max-width: 100%;
    margin: 0;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 998;
    /* animation: slideDown 0.5s ease-out; */
}

/* Adjust main-content khi có search bar fixed */
.search-page-bar ~ .main-content {
    margin-top: 60px;
}

.search-form {
    display: flex;
    gap: 10px;
    position: relative;
    margin-bottom: 0;
}

/* Small search bar on search page */
.search-page-bar .search-form {
    gap: 8px;
}

.search-page-bar .search-form input {
    padding: 8px 12px !important;
    font-size: 0.85rem !important;
}

.search-page-bar .search-button {
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
}

.search-form input {
    flex: 1;
    background-color: var(--bg-light) !important;
    border: 2px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-form input::placeholder {
    color: var(--text-tertiary);
}

.search-form input:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px rgba(245, 107, 124, 0.2) !important;
    outline: none;
}

.search-button {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #ff8a9b 100%);
    color: var(--bg-primary);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 107, 124, 0.4);
}

.search-button:active {
    transform: translateY(0);
}

/* ============================================
   LIVE SEARCH & AUTOCOMPLETE DROPDOWNS
   ============================================ */

.live-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-top: 8px;
    max-height: 0;
    overflow: hidden;
    z-index: 1000;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.live-search-results.show {
    max-height: 600px;
    overflow-y: auto;
    opacity: 1;
    animation: slideDown 0.3s ease-out;
}

/* ============================================
   HIDDEN ELEMENTS (Minimal layout - chỉ cho home page)
   ============================================ */

/* Hide cards chỉ khi ở trang home */
.search-section:not(.search-page-bar) ~ .card {
    display: none;
}

/* ============================================
   SEARCH RESULTS PAGE
   ============================================ */

.search-page-bar {
    margin-bottom: 30px;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 12px;
    border: 1px solid var(--border-primary);
}

.search-results {
    margin-top: 30px;
}

.results-header {
    margin-bottom: 30px;
    animation: slideDown 0.6s ease-out;
}

.results-header h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 700;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: slideUp 0.5s ease-out;
}

.result-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 8px 24px rgba(245, 107, 124, 0.2);
    transform: translateY(-4px);
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-info h3 {
    font-size: 1.15rem;
    margin: 0;
    line-height: 1.5;
    font-weight: 600;
}

.result-info h3 a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.result-info h3 a:hover {
    color: #ff8a9b;
}

.result-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.result-meta .badge {
    display: inline-block;
    background: rgba(245, 107, 124, 0.15);
    color: var(--accent-primary);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.result-description {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.result-actions .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.result-actions .btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.result-actions .btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.result-actions .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.result-actions .btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.result-actions .btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.result-actions .btn-outline-primary {
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.result-actions .btn-outline-primary:hover {
    background-color: rgba(245, 107, 124, 0.1);
}

.result-actions .btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #ff8a9b);
    color: white;
    border: none;
}

.result-actions .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(245, 107, 124, 0.3);
}

/* ============================================
   FILE DETAIL PAGE
   ============================================ */

.file-detail-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.6s ease-out;
}

.file-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 32px;
    background: linear-gradient(135deg, rgba(245, 107, 124, 0.1), rgba(255, 138, 155, 0.05));
    border-bottom: 1px solid var(--border-primary);
    animation: slideDown 0.6s ease-out 0.1s both;
}

.file-detail-icon {
    font-size: 3rem;
    flex-shrink: 0;
}

.file-detail-info {
    flex: 1;
}

.file-detail-info h1 {
    margin: 0 0 16px 0;
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 700;
    word-break: break-word;
}

.file-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.file-meta .badge {
    display: inline-block;
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.file-detail-description {
    padding: 32px;
    border-bottom: 1px solid var(--border-primary);
}

.file-detail-description h3 {
    margin: 0 0 16px 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 700;
}

.file-detail-description p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.file-detail-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 32px;
    border-bottom: 1px solid var(--border-primary);
}

.stat-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
    margin-top: 4px;
}

.file-detail-actions {
    display: flex;
    gap: 16px;
    padding: 32px;
    flex-wrap: wrap;
}

.file-detail-actions .btn {
    flex: 1;
    min-width: 150px;
    padding: 14px 24px;
    font-size: 1rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    animation: slideUp 0.6s ease-out 0.2s both;
}

.file-detail-actions .btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #ff8a9b);
    color: white;
    border: none;
}

.file-detail-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 107, 124, 0.4);
}

.file-detail-actions .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.file-detail-actions .btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--accent-primary);
}

/* ============================================
   PAGINATION
   ============================================ */

.pagination-container {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    padding: 20px 0;
}

.pagination {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.page-item {
    margin: 0;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.page-link:hover:not(.disabled) {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background-color: rgba(245, 107, 124, 0.1);
    transform: translateY(-2px);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--accent-primary), #ff8a9b);
    color: white;
    border-color: var(--accent-primary);
}

.page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    border-radius: 12px;
    border: 1px solid var(--border-primary);
    margin-bottom: 24px;
    animation: slideDown 0.5s ease-out;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.2);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    border-color: rgba(255, 193, 7, 0.2);
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    color: #17a2b8;
    border-color: rgba(23, 162, 184, 0.2);
    margin-top: 50px;
}

.alert-dismissible .btn-close {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .content-container {
        max-width: 100%;
        padding: 16px;
    }

    .search-section {
        padding: 24px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form input,
    .search-button {
        width: 100%;
    }

    .hero {
        padding: 40px 16px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .file-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px;
    }

    .file-detail-info h1 {
        font-size: 1.5rem;
    }

    .file-detail-stats {
        grid-template-columns: 1fr;
    }

    .file-detail-actions {
        flex-direction: column;
    }

    .file-detail-actions .btn {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .app-wrapper {
        min-height: 100vh;
    }

    .main-content {
        margin-top: 70px;
        margin-bottom: 100px;
        padding: 0;
    }

    .content-container {
        max-width: 100%;
        padding: 12px;
        width: 100%;
    }

    /* Search section mobile */
    .search-section {
        padding: 16px;
        border-radius: 8px;
        margin: 0 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .search-form {
        flex-direction: column;
        gap: 8px;
    }

    .search-form input,
    .search-button {
        width: 100%;
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
        border-radius: 8px;
    }

    .search-form input {
        height: 44px;
    }

    .search-button {
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hero mobile */
    .hero {
        padding: 30px 12px;
        margin: 0;
        background: transparent !important;
    }

    .hero::before {
        display: none;
    }

    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    /* Search page bar mobile */
    .search-page-bar {
        top: 70px;
        left: 0;
        right: 0;
        padding: 8px 12px;
        border-radius: 0;
        position: fixed;
    }

    .search-page-bar ~ .main-content {
        margin-top: 130px;
    }

    .search-page-bar .search-form input {
        padding: 8px 12px !important;
        height: 40px;
        font-size: 0.85rem !important;
    }

    .search-page-bar .search-button {
        padding: 8px 12px !important;
        height: 40px;
        font-size: 0.75rem !important;
    }

    .search-page-bar .search-button i {
        margin-right: 4px;
    }

    /* Results grid mobile */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 12px;
    }

    .result-card {
        padding: 14px;
        border-radius: 8px;
    }

    .result-card:hover {
        transform: translateY(-2px);
    }

    .result-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .result-info h3 {
        font-size: 1rem;
    }

    .result-meta {
        gap: 6px;
        font-size: 0.8rem;
    }

    .result-description {
        font-size: 0.85rem;
        margin-bottom: 12px;
        -webkit-line-clamp: 1;
    }

    .result-actions {
        flex-direction: column;
        gap: 8px;
    }

    .result-actions .btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    /* File detail mobile */
    .file-detail-card {
        border-radius: 8px;
        margin: 0 12px;
    }

    .file-detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px 12px;
        gap: 12px;
    }

    .file-detail-icon {
        font-size: 2.5rem;
    }

    .file-detail-info h1 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }

    .file-meta {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .file-meta .badge {
        display: inline-block;
    }

    .file-detail-description {
        padding: 16px 12px;
    }

    .file-detail-description h3 {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .file-detail-description p {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .file-detail-stats {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px 12px;
    }

    .stat-item {
        flex-direction: row;
        align-items: center;
    }

    .stat-item i {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.2rem;
        margin-top: 0;
        margin-left: 8px;
    }

    .file-detail-actions {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }

    .file-detail-actions .btn {
        min-width: auto;
        width: 100%;
        padding: 12px 16px;
        font-size: 0.9rem;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Pagination mobile */
    .pagination-container {
        margin-top: 24px;
        padding: 12px;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .page-link {
        min-width: 36px;
        height: 36px;
        font-size: 0.8rem;
        padding: 0 6px;
    }

    /* Alerts mobile */
    .alert {
        margin: 12px;
        padding: 12px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    /* Footer mobile */
    .footer {
        padding: 20px 12px;
        font-size: 0.85rem;
    }

    .footer-content {
        max-width: 100%;
    }

    .footer p {
        word-break: break-word;
    }

    /* Navbar mobile */
    .navbar-container {
        padding: 0 12px;
    }

    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar-brand img {
        height: 40px;
    }

    .btn-outline-primary {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}
