/**
 * Cosplay Web — Premium Theme v2.0
 * Nâng cấp giao diện: Cosplay-themed, responsive, bảo mật
 */

:root {
    /* Cosplay Brand Colors */
    --cos-primary: #9b59b6;
    --cos-primary-dark: #8e44ad;
    --cos-primary-light: #a855c9;
    --cos-secondary: #e84393;
    --cos-accent: #fd79a8;
    --cos-glow: rgba(155, 89, 182, 0.35);
    
    /* Status Colors */
    --cos-success: #00b894;
    --cos-warning: #fdcb6e;
    --cos-danger: #d63031;
    --cos-info: #0984e3;
    
    /* Background & Surface */
    --cos-bg: #f8f9fc;
    --cos-surface: #ffffff;
    --cos-card-radius: 16px;
    --cos-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --cos-card-shadow-hover: 0 8px 30px rgba(155, 89, 182, 0.15);
    
    /* Layout */
    --cos-sidebar-width: 280px;
    --cos-feed-max: 720px;
    --cos-right-width: 300px;
    --cos-header-height: 60px;
    
    /* Typography */
    --cos-font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --cos-font-display: 'Montserrat', 'Segoe UI', sans-serif;
}

/* ---- Base ---- */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

.cos-body {
    background: var(--cos-bg);
    font-family: var(--cos-font);
    color: #2d3436;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--cos-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Custom Selection */
::selection {
    background: var(--cos-primary);
    color: white;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--cos-primary), var(--cos-secondary));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--cos-primary-dark), var(--cos-secondary));
}

/* ---- Header ---- */
.cos-header {
    z-index: 1030;
}

.cos-logo {
    font-family: var(--cos-font-display);
    font-weight: 800;
    color: #fff;
}

.cos-search-desktop .form-control:focus,
.cos-search-mobile .form-control:focus,
.cos-search-mobile-btn {
    transition: all 0.2s ease;
}

.cos-search-mobile-btn:hover {
    background: rgba(255,255,255,0.3) !important;
}

/* ---- Buttons ---- */
.btn-primary {
    background: linear-gradient(135deg, var(--cos-primary), var(--cos-primary-dark));
    border: none;
    font-weight: 600;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--cos-primary-dark), var(--cos-secondary));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
    color: white;
}

.btn-outline-primary {
    border-color: var(--cos-primary);
    color: var(--cos-primary);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(155, 89, 182, 0.1);
    transform: scale(1.05);
}

.dropdown-toggle-no-caret::after {
    display: none;
}

/* ---- Avatar Sizes ---- */
.cos-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cos-avatar-md {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.cos-avatar-xs {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
}

/* ---- Mobile Navigation ---- */
.cos-nav-mobile {
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.cos-nav-mobile-link {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.65rem;
    line-height: 1.2;
    border-radius: 12px;
    min-width: 60px;
    padding: 8px 4px;
    text-align: center;
    transition: all 0.2s ease;
}

.cos-nav-mobile-link i {
    font-size: 1.2rem;
    display: block;
    margin-bottom: 4px;
}

.cos-nav-mobile-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    font-weight: 600;
}

.cos-nav-mobile-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.cos-nav-mobile-label {
    display: block;
    margin-top: 2px;
    font-weight: 500;
}

/* ---- 3 Column Layout ---- */
.noi-dung-chinh {
    display: grid;
    grid-template-columns: var(--cos-sidebar-width) minmax(0, var(--cos-feed-max)) var(--cos-right-width);
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem 5rem;
    align-items: start;
}

.noi-dung-chinh:not(:has(.cos-sidebar-left)) {
    grid-template-columns: minmax(0, var(--cos-feed-max));
    justify-content: center;
}

.noi-dung-chinh:not(:has(.cos-sidebar-right)):has(.cos-sidebar-left) {
    grid-template-columns: var(--cos-sidebar-width) minmax(0, 1fr);
    max-width: 1000px;
}

.noi-dung-chinh.noi-dung-don {
    grid-template-columns: minmax(0, 560px);
    justify-content: center;
}

.noi-dung-chinh.noi-dung-form {
    grid-template-columns: minmax(0, 720px);
}

/* ---- Product Grid - 5 columns on desktop ---- */
@media (min-width: 992px) {
    .col-lg-5th {
        flex: 0 0 20% !important;
        max-width: 20% !important;
        width: 20% !important;
    }
    
    .col-lg-5th .cos-card-trang .card-body {
        padding: 0.75rem;
    }
    
    .col-lg-5th .cos-card-trang .card-title {
        font-size: 0.85rem;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .col-lg-5th .cos-card-trang .h6,
    .col-lg-5th .cos-card-trang h3 {
        font-size: 0.85rem;
    }
    
    .col-lg-5th .cos-anh-card-sp {
        aspect-ratio: 4/3;
    }
}

/* ---- Cards ---- */
.cos-card-trang {
    border-radius: var(--cos-card-radius);
    border: none;
    box-shadow: var(--cos-card-shadow);
    transition: all 0.3s ease;
    overflow: hidden;
    height: 100%;
}

.cos-card-trang:hover {
    box-shadow: var(--cos-card-shadow-hover);
    transform: translateY(-4px);
}

.cos-feed,
.khu-vuc-chinh {
    min-width: 0;
}

/* ---- Image Previews ---- */
.cos-preview-anh {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 0.5rem;
}

.cos-preview-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.cos-preview-item img,
.cos-preview-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    background: #eee;
    transition: transform 0.2s ease;
}

.cos-preview-item img:hover {
    transform: scale(1.05);
}

.cos-anh-card-sp {
    aspect-ratio: 1;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cos-anh-card-sp:hover {
    transform: scale(1.03);
}

.cos-anh-chi-tiet {
    aspect-ratio: 1;
    object-fit: cover;
    background: #111;
}

.cos-thumb-sp {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
}

.cos-anh-placeholder {
    background: linear-gradient(135deg, #f8f9fc, #e9ecef);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
}

.cos-avatar-nguoi-ban {
    width: 64px;
    height: 64px;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* ---- Sidebar Left ---- */
.cos-sidebar-nav {
    border-radius: var(--cos-card-radius);
    overflow: hidden;
    position: sticky;
    top: 80px;
    background: white;
    box-shadow: var(--cos-card-shadow);
}

.cos-sidebar-link {
    color: #636e72;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin: 2px 8px;
    padding: 12px 16px;
    font-weight: 500;
}

.cos-sidebar-link:hover {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.08), rgba(232, 67, 147, 0.08));
    color: var(--cos-primary);
    transform: translateX(4px);
}

.cos-sidebar-link.active {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.15), rgba(232, 67, 147, 0.1));
    color: var(--cos-primary);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--cos-primary);
}

.cos-sidebar-link i {
    transition: transform 0.2s ease;
}

.cos-sidebar-link:hover i {
    transform: scale(1.1);
}

.cos-sidebar-sub .cos-sidebar-link {
    font-size: 0.9rem;
    color: #636e72;
}

/* ---- Sidebar Right ---- */
.cos-sidebar-right {
    position: sticky;
    top: 80px;
}

.cos-sidebar-right .card {
    border-radius: var(--cos-card-radius);
    border: none;
    box-shadow: var(--cos-card-shadow);
}

.cos-user-list li + li {
    border-top: 1px solid #f0f0f0;
}

/* ---- Feed & Posts ---- */
.cos-hop-dang-bai,
.cos-the-bai-viet {
    border-radius: var(--cos-card-radius) !important;
}

.cos-input-gia {
    border-radius: 999px !important;
    cursor: pointer;
    height: 44px;
    transition: all 0.2s ease;
}

.cos-input-gia:hover {
    background-color: rgba(155, 89, 182, 0.1) !important;
    border-color: var(--cos-primary);
}

.cos-anh-bai-viet {
    max-height: 480px;
    object-fit: cover;
    border-radius: 12px;
}

.cos-nut-tuong-tac {
    font-size: 0.875rem;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.cos-nut-tuong-tac:hover {
    background: rgba(155, 89, 182, 0.08);
}

.cos-nut-tuong-tac.active,
.cos-nut-tuong-tac.active i {
    color: var(--cos-danger) !important;
    background: rgba(214, 48, 49, 0.08);
}

/* ---- Badges ---- */
.badge {
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
}

/* ---- Alerts & Messages ---- */
.loi {
    color: #842029;
    background: linear-gradient(135deg, #f8d7da, #f5c2c7);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thanh-cong {
    color: #0f5132;
    background: linear-gradient(135deg, #d1e7dd, #badbcc);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: 12px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--cos-primary);
    box-shadow: 0 0 0 4px rgba(155, 89, 182, 0.1);
}

.form-label {
    font-weight: 600;
    color: #2d3436;
    margin-bottom: 8px;
}

/* ---- Avatar Large ---- */
.avatar-lon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* ---- Footer ---- */
.cos-footer {
    margin-top: auto;
}

/* ---- Loading Animation ---- */
@keyframes cosPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.cos-loading {
    animation: cosPulse 1.5s ease-in-out infinite;
}

/* ---- Hover Effects ---- */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(155, 89, 182, 0.2);
}

/* ---- Gradient Backgrounds ---- */
.gradient-primary {
    background: linear-gradient(135deg, var(--cos-primary), var(--cos-secondary));
}

.gradient-success {
    background: linear-gradient(135deg, #00b894, #00cec9);
}

.gradient-danger {
    background: linear-gradient(135deg, #d63031, #e17055);
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1199.98px) {
    .noi-dung-chinh {
        grid-template-columns: 240px minmax(0, 1fr);
    }
    
    .cos-sidebar-right {
        display: none;
    }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 991.98px) {
    .noi-dung-chinh {
        grid-template-columns: 1fr;
        max-width: var(--cos-feed-max);
        padding-top: 0.75rem;
        padding-bottom: 6rem;
    }
    
    .cos-sidebar-left {
        display: none !important;
    }
    
    .cos-header-row {
        min-height: 56px;
    }
}

/* ---- Responsive: Small Mobile ---- */
@media (max-width: 575.98px) {
    :root {
        --cos-card-radius: 12px;
    }
    
    .noi-dung-chinh {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .cos-card-trang {
        border-radius: 12px;
    }
}

/* ---- Admin Theme ---- */
body.admin {
    background: linear-gradient(180deg, #f4f7fb 0%, #eef1f6 100%);
    color: #243247;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e4e9f1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.admin-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-header a {
    color: #62718a;
    text-decoration: none;
    font-weight: 600;
    font-size: .86rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.admin-header a:hover {
    background: rgba(155, 89, 182, 0.1);
    color: var(--cos-primary);
}

.admin-brand { 
    color: var(--cos-primary) !important; 
    font-size: 1.1rem !important; 
    font-weight: 800 !important;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--cos-primary), var(--cos-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-brand small {
    font-size: .6rem;
    letter-spacing: .1em;
    background: var(--cos-primary);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.admin-site {
    margin-left: auto;
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.1), rgba(232, 67, 147, 0.1));
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--cos-primary) !important;
}

.admin-main {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.thong-ke {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.thong-ke .the {
    background: linear-gradient(135deg, #fff, #f8f9fc);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    font-size: 1rem;
    box-shadow: var(--cos-card-shadow);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.thong-ke .the:hover {
    transform: translateY(-4px);
    box-shadow: var(--cos-card-shadow-hover);
}

.bang-admin {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: #fff;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--cos-card-shadow);
}

.bang-admin th,
.bang-admin td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid #f0f2f5;
}

.bang-admin th {
    background: linear-gradient(135deg, #f8f9fc, #fff);
    color: #63718a;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bang-admin .row-cho td { 
    background: linear-gradient(90deg, rgba(230, 126, 34, 0.06), transparent); 
}

.bang-admin .row-duyet td { 
    background: linear-gradient(90deg, rgba(39, 174, 96, 0.04), transparent); 
}

/* ---- Utility Classes ---- */
.text-gradient {
    background: linear-gradient(135deg, var(--cos-primary), var(--cos-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border-image: linear-gradient(135deg, var(--cos-primary), var(--cos-secondary)) 1;
}

.shadow-gradient {
    box-shadow: 0 4px 20px rgba(155, 89, 182, 0.25);
}

/* ---- Page Transitions ---- */
.page-enter {
    opacity: 0;
    transform: translateY(10px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ═══════════════════════════════════════════
   TOUCH-FRIENDLY CARD IMPROVEMENTS
   ═══════════════════════════════════════════ */
/* Tăng touch target cho mobile */
@media (max-width: 991.98px) {
    .cos-card-trang .card-body {
        padding: 1rem;
    }
    
    .btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Card hover effect vô hiệu hóa trên touch */
    @media (hover: none) {
        .cos-card-trang:hover {
            transform: none !important;
            box-shadow: var(--cos-card-shadow) !important;
        }
    }
}

/* Giảm spacing cho màn hình nhỏ */
@media (max-width: 575.98px) {
    .cos-hero-actions .btn {
        min-height: 44px;
        font-size: 0.85rem;
    }
}

/* ============================================
   FORCE 5 COLUMNS ON DESKTOP - OVERRIDE ALL
   ============================================ */
@media (min-width: 992px) {
    .khu-vuc-chinh .row.g-2.g-md-3 > div {
        flex: 0 0 20% !important;
        max-width: 20% !important;
        width: 20% !important;
    }
    
    .khu-vuc-chinh .row.g-2.g-md-3 > div.col-6 {
        flex: 0 0 20% !important;
        max-width: 20% !important;
    }
}
