:root {
    --mint: #45fb9d;
    --dark-bg: #0a0a0a;
    --card-bg: rgba(20, 20, 20, 0.95);
    --gray-text: #999;
    --border-color: rgba(255, 255, 255, 0.1);
    --header-height: 80px;
    --sidebar-width: 250px;
}

/* Основно нулиране */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

/* Базов изглед - Използва се за центриране на Вход/Регистрация */
body {
    background-color: var(--dark-bg);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    color: white;
}

/* Изглед за Дашборд - за страници с менюта (home.html/admin.html) */
body.dashboard-body {
    display: block;
    overflow: hidden;
}

/* Ефект на фоново сияние */
.bg-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: var(--mint);
    filter: blur(200px);
    opacity: 0.07;
    z-index: -1;
    pointer-events: none;
}

/* ГЛАВНИ КОМПОНЕНТИ (КАРТИ) */
/* .modal - removed as unused, using .modal-overlay instead */

.modal-content,
.login-card {
    background: var(--card-bg);
    border: 1px solid rgba(148, 255, 219, 0.1);
    padding: 60px 45px;
    border-radius: 60px;
    max-width: 480px;
    width: 92%;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.9);
    position: relative;
    z-index: 10;
}

/* Входни полета (Inputs) */
.input-wrapper {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
}

.input-wrapper i {
    position: absolute;
    left: 25px;
    top: 28px; /* Fixed distance from top instead of 50% to prevent misplacement with descriptions */
    transform: translateY(-50%);
    color: var(--gray-text);
    font-size: 1.1rem;
    z-index: 5;
}

.input-wrapper input {
    padding-left: 60px;
    margin-bottom: 0;
}

input {
    width: 100%;
    padding: 18px 28px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: 0.3s;
}

input:focus {
    border-color: var(--mint);
    background: rgba(148, 255, 219, 0.05);
}

/* МОДАЛНИ ПРОЗОРЦИ (СИСТЕМА ЗА ПЛАВНО ПОЯВЯВАНЕ) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 2000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay .modal-content {
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.4s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

/* СТРУКТУРА НА ГОРНОТО МЕНЮ (HEADER) */
.top-header {
    height: var(--header-height);
    width: 100%;
    display: none;
    /* Скрито по подразбиране */
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    border-bottom: 2px solid var(--border-color);
    background: var(--dark-bg);
    position: fixed;
    top: 0;
    z-index: 1000;
}

.top-header.show-nav {
    display: flex !important;
}

.header-nav {
    display: flex;
    gap: 40px;
    align-items: center;
}

.header-nav a,
.logout-link {
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    padding-bottom: 4px;
}

.header-nav a::after,
.logout-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--mint);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-nav a:hover,
.logout-link:hover {
    opacity: 1;
    color: var(--mint);
}

.header-nav a:hover::after,
.logout-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* СТРУКТУРА НА СТРАНИЧНОТО МЕНЮ (SIDEBAR) */
.main-wrapper {
    display: flex;
    padding-top: var(--header-height);
    height: 100vh;
}

.left-sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    border-right: 2px solid var(--border-color);
    padding: 40px 20px;
    background: rgba(10, 10, 10, 0.5);
    display: none;
}

.left-sidebar.show-nav {
    display: block !important;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-link {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.5;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 12px 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    transform: translateX(6px);
}

.sidebar-link:hover,
.sidebar-link.active {
    opacity: 1;
    color: var(--mint);
    background: rgba(148, 255, 219, 0.05);
}

.sidebar-link.active {
    border-left: 3px solid var(--mint);
    padding-left: 20px;
}

/* ОСНОВНА ЗОНА ЗА СЪДЪРЖАНИЕ */
.content-area {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    width: 100%;
    animation: fadeIn 0.4s ease;
}

/* АДМИН ПАНЕЛ - КАРТИ И МРЕЖА */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 30px;
    width: 100%;
}

.news-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 30px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    display: flex;
    gap: 35px;
    align-items: center;
}

.news-card:hover {
    border-color: var(--mint);
    background: rgba(148, 255, 219, 0.02);
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 10px 30px rgba(69, 251, 157, 0.08);
}

.news-img-side {
    width: 280px;
    height: 180px;
    flex-shrink: 0;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
    transition: 0.3s;
}

.news-img-side:hover {
    transform: scale(1.03);
    border-color: var(--mint);
}

.news-img-side img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-text-side {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* IMAGE POPUP SYSTEM */
#image-viewer-modal .modal-content {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 90vw;
    width: auto;
}

#viewer-image {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 20px;
    border: 2px solid var(--mint);
    box-shadow: 0 0 50px rgba(148, 255, 219, 0.3);
}

.admin-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s;
}

.admin-card:hover {
    border-color: var(--mint);
    transform: translateY(-5px);
    background: rgba(148, 255, 219, 0.02);
}

.user-info strong {
    display: block;
    color: var(--mint);
    font-size: 1.1rem;
}

.user-info span {
    color: var(--gray-text);
    font-size: 0.8rem;
}

.admin-actions {
    display: flex;
    gap: 12px;
}

.admin-actions button {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

/* Бутони за Одобрение и Изтриване */
.btn-approve {
    background: rgba(148, 255, 219, 0.1);
    color: var(--mint);
    border: 1px solid var(--mint) !important;
}

.btn-approve:hover {
    background: var(--mint);
    color: #000;
    box-shadow: 0 0 20px var(--mint);
}

.btn-deny {
    background: rgba(255, 95, 95, 0.1);
    color: #ff5f5f;
    border: 1px solid #ff5f5f !important;
}

.btn-deny:hover {
    background: #ff5f5f;
    color: #fff;
    box-shadow: 0 0 20px #ff5f5f;
}

/* Typography and decorations */
h2 {
    font-size: 3.2rem;
    font-weight: 900;
    margin-bottom: 20px;
    letter-spacing: -2px;
}

h3 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 14px;
    letter-spacing: 0;
    color: #cacaca;
}

.nav-logo {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--mint);
    border: 2px solid var(--mint);
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.status-pill {
    display: inline-block;
    box-shadow: 0 0 30px rgba(148, 255, 219, 0.5);
    border: 1.5px solid var(--mint);
    color: var(--mint);
    padding: 6px 22px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 25px;
    text-transform: uppercase;
}

.neon-pill-footer {
    display: inline-block;
    color: #fff;
    background: transparent;
    border: 2px solid var(--mint);
    padding: 18px 45px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 0 60px rgba(148, 255, 219, 0.2);
    transition: all 0.4s ease;
}

.neon-pill-footer:hover {
    background: var(--mint);
    color: #000;
    box-shadow: 0 0 40px var(--mint);
    transform: scale(1.02);
}

/* Muted button style for credits payment (no green hover) */
.neon-pill-muted {
    display: inline-block;
    color: var(--gray-text);
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.2);
    padding: 18px 45px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: none;
}

.neon-pill-muted:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
    color: white;
    box-shadow: 0 0 20px rgba(255,255,255,0.1);
    transform: scale(1.02);
}

.error-text {
    color: #ff5f5f;
    font-size: 0.8rem;
    margin-top: 20px;
    font-weight: 600;
    min-height: 1rem;
}

.success-text {
    color: var(--mint);
    font-size: 0.8rem;
    margin-top: 20px;
    font-weight: 600;
    min-height: 1rem;
}

.description {
    color: var(--gray-text);
    font-size: 0.95rem;
    margin-bottom: 35px;
    line-height: 1.6;
}

/* ПРОГРЕС БАР */
.progress-bar {
    height: 6px;
    background: #1a1a1a;
    border-radius: 100px;
    margin: 15px 40px 45px;
    overflow: hidden;
}

.fill {
    height: 100%;
    background: var(--mint);
    box-shadow: 0 0 15px var(--mint);
}

/* --- TOAST NOTIFICATION SYSTEM --- */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 20px 25px;
    border-radius: 20px;
    min-width: 300px;
    max-width: 450px;
    color: white;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    backdrop-filter: blur(20px);
}

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

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

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

.toast-content {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    padding-right: 20px;
}

.toast-close {
    background: rgba(255, 95, 95, 0.1);
    color: #ff5f5f;
    border: 1px solid rgba(255, 95, 95, 0.2);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    transition: 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: #ff5f5f;
    color: white;
    transform: scale(1.1);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--mint);
    width: 100%;
    transform-origin: left;
    animation: toastProgress 5s linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.toast.error .toast-progress {
    background: #ff5f5f;
}

.toast.success .toast-progress {
    background: var(--mint);
}

/* ПОМОЩНИ КЛАСОВЕ И АНИМАЦИИ */
.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

.section-fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.section-fade-out {
    animation: fadeOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* SIDEBAR SWITCH ANIMATION */
.sidebar-nav {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.sidebar-nav.hidden {
    display: none !important;
}

/* Ensure sections have a consistent starting point for animations */
.content-area > section {
    width: 100%;
}

.logo-faded {
    position: fixed;
    font-size: 15vw;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.02);
    text-transform: uppercase;
    z-index: -1;
    bottom: 0;
    right: 0;
    pointer-events: none;
}

/* HIDE CONTENT BEFORE AUTHENTICATION */
/* First, hide everything so home/admin is not visible for a fraction of a second */
body.dashboard-body {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* A class to add via JavaScript when we confirm the user */
body.auth-checked {
    opacity: 1;
}

/* Styling for redirect message (optional) - kept for future use */
/* .redirect-overlay { position: fixed; ... } */

select {
    width: 100%;
    padding: 18px 28px;
    padding-left: 60px;
    /* За да остане място за иконата */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    appearance: none;
    /* Премахва системната стрелка на браузъра */
    cursor: pointer;
    transition: 0.3s;
}

select:focus {
    border-color: var(--mint);
    background: rgba(148, 255, 219, 0.05);
}

/* Стилизиране на опциите вътре в менюто */
select option {
    background: #1a1a1a;
    color: white;
}

/* TEXTAREA STYLE (bigger message box) */
.textarea-wrapper textarea {
    width: 100%;
    min-height: 140px;
    padding: 18px 28px;
    padding-left: 60px;
    border-radius: 20px; /* less rounded than inputs */
    resize: none;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: 0.3s;
}

/* focus effect */
.textarea-wrapper textarea:focus {
    border-color: var(--mint);
    background: rgba(148, 255, 219, 0.05);
}

/* move icon to top for textarea */
.textarea-wrapper i {
    top: 28px;
    transform: translateY(-50%);
}

/* CHARACTER COUNTER */
.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: var(--gray-text);
    margin-top: 6px;
    padding-right: 10px;
}

.report-form {
    width: 100%;
    max-width: none;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    width: 100%;
    margin-top: 30px;
}

.report-grid .full-width {
    grid-column: 1 / -1;
}

/* make textarea stretch properly */
.report-form .textarea-wrapper textarea {
    width: 100%;
}

/* button alignment */
.report-form .neon-pill-footer {
    margin-top: 25px;
}

/* TEXT DIVIDER (progress-bar style) */
.divider-bar {
    height: 2px; /* thinner than progress bar */
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    margin: 30px 0;
    overflow: hidden;
    position: relative;
}

/* glowing line (optional animated accent) */
.divider-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: -40%;
    height: 100%;
    width: 40%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--mint),
        transparent
    );
    animation: divider-slide 2.5s infinite linear;
    opacity: 0.8;
}

@keyframes divider-slide {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

/* SUBSCRIPTION PLANS SYSTEM */
.plans-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 50px;
    width: 100%;
}

.plan-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 50px 40px;
    border-radius: 40px;
    text-align: center;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.plan-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(148, 255, 219, 0.1), transparent 70%);
    opacity: 0;
    transition: 0.5s;
}

.plan-card:hover {
    transform: translateY(-15px) scale(1.02);
    border-color: var(--mint);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(148, 255, 219, 0.1);
}

.plan-card:hover::before {
    opacity: 1;
}

.plan-tag {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--mint);
    background: rgba(148, 255, 219, 0.1);
    padding: 8px 20px;
    border-radius: 100px;
    margin-bottom: 25px;
    text-transform: uppercase;
}

.plan-card h3 {
    font-size: 1.8rem;
    color: white;
    margin-bottom: 15px;
}

.plan-card .price {
    font-size: 2.5rem;
    font-weight: 900;
    color: white;
    margin-bottom: 30px;
}

.plan-card .price::after {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    background: var(--mint);
    margin: 15px auto 0;
    border-radius: 10px;
}

.plan-card ul {
    list-style: none;
    margin-bottom: 40px;
    text-align: left;
    width: 100%;
}

.plan-card ul li {
    color: var(--gray-text);
    font-size: 0.95rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.plan-card ul li::before {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: var(--mint);
    font-size: 0.8rem;
}

.plan-btn {
    width: 100%;
    padding: 18px;
    border-radius: 100px;
    border: 1px solid var(--mint);
    background: transparent;
    color: var(--mint);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: 0.3s;
    margin-top: auto;
}

.plan-btn:hover {
    background: var(--mint);
    color: black;
    box-shadow: 0 0 30px var(--mint);
}
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {

    // Helper: Check if request is authenticated
    function isAuthenticated() {
      return request.auth != null;
    }

    // Helper: Check if authenticated user matches target record owner
    function isOwner(userId) {
      return isAuthenticated() && request.auth.uid == userId;
    }

    // Helper: Retrieve the role of the active user profile
    function getUserRole() {
      return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.get('role', 'user');
    }

    // Helper: Check if active user is a verified administrator
    function isAdmin() {
      return isAuthenticated() 
        && exists(/databases/$(database)/documents/users/$(request.auth.uid))
        && getUserRole() == 'admin';
    }

    // 1. User Profiles Collection Access Controls
    match /users/{userId} {
      // Users can read their own profiles, admins can query all documents
      allow read: if isOwner(userId) || isAdmin();
      
      // Prevent privilege escalation during registration
      allow create: if isAuthenticated() 
        && request.auth.uid == userId
        && request.resource.data.get('role', 'user') == 'user'
        && request.resource.data.get('freezes', 0) == 0
        && request.resource.data.get('is_frozen_1', false) == false
        && request.resource.data.get('is_frozen_2', false) == false;

      // Restrict unauthorized direct writes to sensitive subscription details
      allow update: if isAdmin() || (
        isOwner(userId)
        && request.resource.data.get('role', 'user') == resource.data.get('role', 'user') // Block role change
        && request.resource.data.get('email', '') == resource.data.get('email', '') // Block email changes
        && (
          // Transition 1: Freeze Subscription (Internal / Expiry 1)
          (
            request.resource.data.get('is_frozen_1', false) == true
            && resource.data.get('is_frozen_1', false) == false
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0) - 1
            && request.resource.data.get('frozen_time_1', null) != null
            && resource.data.get('expiry_date_1', null) != null
            && request.resource.data.get('expiry_date_1', null) != null
            && request.resource.data.get('expiry_date_1', null).toMillis() == resource.data.get('expiry_date_1', null).toMillis() + 1209600000
               // Expiry date must be extended by exactly 14 days
            // Ensure Skin-Changer fields are untouched
            && request.resource.data.get('is_frozen_2', false) == resource.data.get('is_frozen_2', false)
            && request.resource.data.get('frozen_time_2', null) == resource.data.get('frozen_time_2', null)
            && request.resource.data.get('expiry_date_2', null) == resource.data.get('expiry_date_2', null)
          ) ||
          // Transition 2: Freeze Subscription (Skin-Changer / Expiry 2)
          (
            request.resource.data.get('is_frozen_2', false) == true
            && resource.data.get('is_frozen_2', false) == false
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0) - 1
            && request.resource.data.get('frozen_time_2', null) != null
            && resource.data.get('expiry_date_2', null) != null
            && request.resource.data.get('expiry_date_2', null) != null
            && request.resource.data.get('expiry_date_2', null).toMillis() == resource.data.get('expiry_date_2', null).toMillis() + 1209600000
               // Expiry date must be extended by exactly 14 days
            // Ensure Internal fields are untouched
            && request.resource.data.get('is_frozen_1', false) == resource.data.get('is_frozen_1', false)
            && request.resource.data.get('frozen_time_1', null) == resource.data.get('frozen_time_1', null)
            && request.resource.data.get('expiry_date_1', null) == resource.data.get('expiry_date_1', null)
          ) ||
          // Transition 3: Unfreeze Subscription (Internal / Expiry 1)
          (
            request.resource.data.get('is_frozen_1', false) == false
            && resource.data.get('is_frozen_1', false) == true
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0)
            && request.resource.data.get('frozen_time_1', null) == null
            && resource.data.get('expiry_date_1', null) != null
            && resource.data.get('frozen_time_1', null) != null
            && request.resource.data.get('expiry_date_1', null) != null
            // Check that the updated expiry_date_1 matches the calculated value (with latency buffer)
            && (
              (request.time < resource.data.get('frozen_time_1', request.time))
                ? (request.resource.data.get('expiry_date_1', request.time).toMillis() <= resource.data.get('expiry_date_1', request.time).toMillis() - (resource.data.get('frozen_time_1', request.time).toMillis() - request.time.toMillis()) + 15000
                   && request.resource.data.get('expiry_date_1', request.time).toMillis() >= resource.data.get('expiry_date_1', request.time).toMillis() - (resource.data.get('frozen_time_1', request.time).toMillis() - request.time.toMillis()) - 15000)
                : (request.resource.data.get('expiry_date_1', request.time).toMillis() <= resource.data.get('expiry_date_1', request.time).toMillis() + 15000
                   && request.resource.data.get('expiry_date_1', request.time).toMillis() >= resource.data.get('expiry_date_1', request.time).toMillis() - 15000)
            )
            // Ensure Skin-Changer fields are untouched
            && request.resource.data.get('is_frozen_2', false) == resource.data.get('is_frozen_2', false)
            && request.resource.data.get('frozen_time_2', null) == resource.data.get('frozen_time_2', null)
            && request.resource.data.get('expiry_date_2', null) == resource.data.get('expiry_date_2', null)
          ) ||
          // Transition 4: Unfreeze Subscription (Skin-Changer / Expiry 2)
          (
            request.resource.data.get('is_frozen_2', false) == false
            && resource.data.get('is_frozen_2', false) == true
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0)
            && request.resource.data.get('frozen_time_2', null) == null
            && resource.data.get('expiry_date_2', null) != null
            && resource.data.get('frozen_time_2', null) != null
            && request.resource.data.get('expiry_date_2', null) != null
            // Check that the updated expiry_date_2 matches the calculated value (with latency buffer)
            && (
              (request.time < resource.data.get('frozen_time_2', request.time))
                ? (request.resource.data.get('expiry_date_2', request.time).toMillis() <= resource.data.get('expiry_date_2', request.time).toMillis() - (resource.data.get('frozen_time_2', request.time).toMillis() - request.time.toMillis()) + 15000
                   && request.resource.data.get('expiry_date_2', request.time).toMillis() >= resource.data.get('expiry_date_2', request.time).toMillis() - (resource.data.get('frozen_time_2', request.time).toMillis() - request.time.toMillis()) - 15000)
                : (request.resource.data.get('expiry_date_2', request.time).toMillis() <= resource.data.get('expiry_date_2', request.time).toMillis() + 15000
                   && request.resource.data.get('expiry_date_2', request.time).toMillis() >= resource.data.get('expiry_date_2', request.time).toMillis() - 15000)
            )
            // Ensure Internal fields are untouched
            && request.resource.data.get('is_frozen_1', false) == resource.data.get('is_frozen_1', false)
            && request.resource.data.get('frozen_time_1', null) == resource.data.get('frozen_time_1', null)
            && request.resource.data.get('expiry_date_1', null) == resource.data.get('expiry_date_1', null)
          ) ||
          // Transition 5: License Key Redemption
          (
            request.resource.data.get('last_redeemed_key', null) != null
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0) + 1
            // Fetch key details securely from the database
            && get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('is_used', false) == true
            && get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('used_by', '') == request.auth.uid
            // Key update must have happened within the last 60 seconds (prevents reuse exploits)
            && request.time.toMillis() < get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('used_at', request.time).toMillis() + 60000
            && (
              // Case 5a: Redemption for CS2 Internal (key_type == '1')
              (
                get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('key_type', '') == '1'
                // Check that the expiry date is extended correctly based on key duration
                && request.resource.data.get('expiry_date_1', request.time).toMillis() >= 
                   ((resource.data.get('expiry_date_1', null) == null || resource.data.get('expiry_date_1', request.time).toMillis() < request.time.toMillis()
                     ? request.time.toMillis()
                     : resource.data.get('expiry_date_1', request.time).toMillis())
                    + get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('duration_days', 0) * 86400000) - 15000
                && request.resource.data.get('expiry_date_1', request.time).toMillis() <= 
                   ((resource.data.get('expiry_date_1', null) == null || resource.data.get('expiry_date_1', request.time).toMillis() < request.time.toMillis()
                     ? request.time.toMillis()
                     : resource.data.get('expiry_date_1', request.time).toMillis())
                    + get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('duration_days', 0) * 86400000) + 15000
                // Ensure Skin-Changer fields are untouched
                && request.resource.data.get('is_frozen_2', false) == resource.data.get('is_frozen_2', false)
                && request.resource.data.get('frozen_time_2', null) == resource.data.get('frozen_time_2', null)
                && request.resource.data.get('expiry_date_2', null) == resource.data.get('expiry_date_2', null)
              ) ||
              // Case 5b: Redemption for CS2 Skin-Changer (key_type == '2')
              (
                get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('key_type', '') == '2'
                // Check that the expiry date is extended correctly based on key duration
                && request.resource.data.get('expiry_date_2', request.time).toMillis() >= 
                   ((resource.data.get('expiry_date_2', null) == null || resource.data.get('expiry_date_2', request.time).toMillis() < request.time.toMillis()
                     ? request.time.toMillis()
                     : resource.data.get('expiry_date_2', request.time).toMillis())
                    + get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('duration_days', 0) * 86400000) - 15000
                && request.resource.data.get('expiry_date_2', request.time).toMillis() <= 
                   ((resource.data.get('expiry_date_2', null) == null || resource.data.get('expiry_date_2', request.time).toMillis() < request.time.toMillis()
                     ? request.time.toMillis()
                     : resource.data.get('expiry_date_2', request.time).toMillis())
                    + get(/databases/$(database)/documents/license_keys/$(request.resource.data.get('last_redeemed_key', ''))).data.get('duration_days', 0) * 86400000) + 15000
                // Ensure Internal fields are untouched
                && request.resource.data.get('is_frozen_1', false) == resource.data.get('is_frozen_1', false)
                && request.resource.data.get('frozen_time_1', null) == resource.data.get('frozen_time_1', null)
                && request.resource.data.get('expiry_date_1', null) == resource.data.get('expiry_date_1', null)
              )
            )
          ) ||
          // Transition 6: Safe profile save of non-sensitive attributes (e.g. HWID linked, profile edits, auto-repairs)
          (
            request.resource.data.get('role', 'user') == resource.data.get('role', 'user')
            && request.resource.data.get('freezes', 0) == resource.data.get('freezes', 0)
            && request.resource.data.get('is_frozen_1', false) == resource.data.get('is_frozen_1', false)
            && request.resource.data.get('is_frozen_2', false) == resource.data.get('is_frozen_2', false)
            && request.resource.data.get('frozen_time_1', null) == resource.data.get('frozen_time_1', null)
            && request.resource.data.get('frozen_time_2', null) == resource.data.get('frozen_time_2', null)
            && request.resource.data.get('expiry_date_1', null) == resource.data.get('expiry_date_1', null)
            && request.resource.data.get('expiry_date_2', null) == resource.data.get('expiry_date_2', null)
          )
        )
      );

      // Only administrators can purge user data
      allow delete: if isAdmin();
    }

    // 2. License Keys Collection Access Controls
    match /license_keys/{keyId} {
      // Key creation and purges are restricted to verified administrators
      allow create, delete: if isAdmin();
      
      // Regular users can look up individual key documents to redeem them, but cannot list all keys
      allow get: if isAuthenticated();
      allow list: if isAdmin();
      
      // Standard users can update key status to activated/used during redemption, and admins can edit any key fields
      allow update: if isAdmin() || (
        isAuthenticated()
        && resource.data.get('is_used', false) == false
        && request.resource.data.get('is_used', false) == true
        && request.resource.data.get('used_by', '') == request.auth.uid
      );
    }

    // 3. Global System Cheat Status Sync Controls
    match /system/cheat_statuses {
      // Anybody (including guest landing views) can read real-time status feeds
      allow read: if true;
      // Only administrators can change statuses
      allow write: if isAdmin();
    }

    // 4. Product Ratings & Comments Reviews Collection Access Controls
    match /reviews/{reviewId} {
      // Anybody can browse verified review feeds
      allow read: if true;
      
      // Creating or editing comments requires verified authentication matching the user record
      allow create, update: if isAuthenticated()
        && request.resource.data.get('userId', '') == request.auth.uid
        && request.resource.data.get('rating', 0) >= 1 
        && request.resource.data.get('rating', 0) <= 5
        && request.resource.data.get('comment', '').size() <= 500; // Payload bounds check
      
      // Only the author or an administrator can delete comments
      allow delete: if isAuthenticated() && (
        resource.data.get('userId', '') == request.auth.uid 
        || isAdmin()
      );
    }
  }
}

/* Specific Tier Styles */
.plan-card.premium {
    border-color: rgba(148, 255, 219, 0.4);
    background: rgba(148, 255, 219, 0.02);
}

.plan-card.premium .plan-tag {
    background: var(--mint);
    color: black;
    box-shadow: 0 0 20px var(--mint);
}

.plan-card.premium .plan-btn {
    background: var(--mint);
    color: black;
}

/* USER ICON & DROPDOWN */
.user-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(148, 255, 219, 0.1);
    border: 2px solid var(--mint);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    color: var(--mint);
    font-size: 1rem;
}

.user-icon:hover {
    background: rgba(148, 255, 219, 0.2);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(148, 255, 219, 0.3);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(148, 255, 219, 0.2);
    border-radius: 20px;
    padding: 10px;
    min-width: 220px;
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 1003;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.user-dropdown.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.user-dropdown .dropdown-link {
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 12px 18px;
    border-radius: 12px;
    transition: 0.3s;
    text-transform: none;
    letter-spacing: 0;
    opacity: 1;
}

.user-dropdown .dropdown-link:hover {
    background: rgba(148, 255, 219, 0.1);
    color: var(--mint);
}

.user-dropdown .logout-link {
    color: #ff5f5f;
    border-top: 1px solid var(--border-color);
    margin-top: 5px;
    padding-top: 15px;
}

.user-dropdown .logout-link:hover {
    background: rgba(255, 95, 95, 0.1);
    color: #ff5f5f;
}

/* MOBILE MENU */
.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left {
    z-index: 1002;
}

.user-icon-wrapper {
    position: relative;
    z-index: 1002;
}

.mobile-menu-wrapper {
    display: none;
    position: relative;
}

.mobile-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(148, 255, 219, 0.1);
    border: 2px solid var(--mint);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    color: var(--mint);
    font-size: 1rem;
}

.mobile-menu-btn:hover {
    background: rgba(148, 255, 219, 0.2);
    transform: scale(1.05);
}

.mobile-nav-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(148, 255, 219, 0.2);
    border-radius: 20px;
    padding: 10px;
    min-width: 220px;
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 1003;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.mobile-nav-dropdown.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.mobile-nav-dropdown a {
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 12px 18px;
    border-radius: 12px;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-nav-dropdown a:hover {
    background: rgba(148, 255, 219, 0.1);
    color: var(--mint);
}

/* Checkbox Styling */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    text-align: left;
    padding: 0 10px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--mint);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-wrapper label {
    font-size: 0.85rem;
    color: var(--gray-text);
    cursor: pointer;
    line-height: 1.4;
    user-select: none;
}

.checkbox-wrapper a {
    color: var(--mint);
    text-decoration: none;
    font-weight: 600;
}

.checkbox-wrapper a:hover {
    text-decoration: underline;
}

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

/* Tablets and smaller desktops */
@media (max-width: 1024px) {
    .main-wrapper {
        flex-direction: column;
    }

    .left-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        padding: 20px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .sidebar-link {
        padding: 8px 15px;
        font-size: 0.8rem;
    }

    .sidebar-link.active {
        border-left: none;
        border-bottom: 3px solid var(--mint);
        padding-left: 15px;
        padding-bottom: 8px;
    }

    .content-area {
        padding: 20px;
    }

    h2 {
        font-size: 2.5rem;
    }

    .plans-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .top-header {
        padding: 0 15px;
    }

    #desktop-nav {
        display: none;
    }

    .mobile-menu-wrapper {
        display: block;
    }

    .header-nav {
        gap: 15px;
    }

    .header-nav a,
    .logout-link {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }

    .nav-logo {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }

    .user-icon {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .user-dropdown {
        min-width: 180px;
        right: -10px;
    }

    h2 {
        font-size: 2rem;
        letter-spacing: -1px;
    }

    h3 {
        font-size: 1.4rem;
    }

    .content-area {
        padding: 15px;
    }

    .news-card {
        flex-direction: column;
    }

    .news-img-side {
        width: 100%;
        height: 200px;
    }

    .plans-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .plan-card {
        padding: 30px 25px;
    }

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

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

    .modal-content,
    .login-card {
        padding: 40px 25px;
        border-radius: 40px;
    }

    .neon-pill-footer {
        padding: 15px 30px;
        font-size: 0.75rem;
    }

    .status-pill {
        font-size: 0.55rem;
        padding: 5px 15px;
    }

    .sidebar-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .sidebar-link {
        white-space: nowrap;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .header-nav {
        gap: 10px;
    }

    .header-nav a,
    .logout-link {
        font-size: 0.65rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    .content-area {
        padding: 10px;
    }

    .modal-content,
    .login-card {
        padding: 30px 20px;
        border-radius: 30px;
    }

    .input-wrapper input,
    .input-wrapper textarea,
    select {
        padding: 14px 20px;
        padding-left: 50px;
        font-size: 0.85rem;
    }

    .input-wrapper i {
        left: 18px;
        font-size: 0.9rem;
    }
}

/* Large screens */
/* ===========================
   TOS PAGE SPECIFIC STYLES
   =========================== */

.tos-card {
    max-width: 680px !important;
    text-align: left;
    padding: 60px 50px;
}

.tos-scroll {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 10px;
    margin: 10px 0 20px;
}

.tos-scroll::-webkit-scrollbar {
    width: 4px;
}

.tos-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.tos-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 255, 219, 0.3);
    border-radius: 10px;
}

.tos-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 255, 219, 0.5);
}

.tos-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: border-color 0.3s, background 0.3s;
}

.tos-section:hover {
    border-color: rgba(148, 255, 219, 0.15);
    background: rgba(148, 255, 219, 0.02);
}

.tos-section-title {
    color: var(--mint);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tos-section-title i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.tos-section p {
    color: var(--gray-text);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.tos-bullets {
    list-style: none;
    margin-top: 8px;
    padding: 0;
}

.tos-bullets li {
    color: var(--gray-text);
    font-size: 0.9rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 2px;
}

.tos-bullets li::before {
    content: "\f00d";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #ff5f5f;
    font-size: 0.65rem;
}

@media (max-width: 768px) {
    .tos-card {
        padding: 40px 25px;
        max-width: 95% !important;
    }

    .tos-scroll {
        max-height: 320px;
    }

    .tos-section {
        padding: 16px 18px;
    }
}

@media (min-width: 1440px) {
    .content-area {
        max-width: 1400px;
        margin: 0 auto;
    }

    .plans-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===========================
   TOAST NOTIFICATIONS
   =========================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(148, 255, 219, 0.3);
    border-radius: 15px;
    padding: 15px 20px;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
}

.toast.hiding {
    animation: toastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success {
    border-color: var(--mint);
}

.toast.success .toast-icon {
    color: var(--mint);
}

.toast.error {
    border-color: #ff5f5f;
}

.toast.error .toast-icon {
    color: #ff5f5f;
}

.toast.info {
    border-color: #5fbaff;
}

.toast.info .toast-icon {
    color: #5fbaff;
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray-text);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: 0.2s;
}

.toast-close:hover {
    color: white;
}

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

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

@media (max-width: 480px) {
    .toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

/* --- TICKETS & CHAT SYSTEM STYLES --- */
.tickets-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    margin-top: 30px;
    height: calc(100vh - var(--header-height) - 200px);
    min-height: 550px;
}

@media (max-width: 1024px) {
    .tickets-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.tickets-sidebar-pane {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
}

.tickets-sidebar-pane::-webkit-scrollbar {
    width: 6px;
}
.tickets-sidebar-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.tickets-chat-pane {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.ticket-creation-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 25px;
}

.ticket-creation-card h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: white;
}

.ticket-list-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ticket-list-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
}

.ticket-list-item:hover,
.ticket-list-item.active {
    border-color: var(--mint);
    background: rgba(148, 255, 219, 0.02);
}

.ticket-list-item.active {
    box-shadow: 0 0 20px rgba(148, 255, 219, 0.05);
}

.ticket-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ticket-item-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.ticket-item-type {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 700;
    text-transform: uppercase;
}

.ticket-item-type.help {
    background: rgba(255, 95, 95, 0.1);
    color: #ff5f5f;
    border: 1px solid rgba(255, 95, 95, 0.2);
}

.ticket-item-type.sub {
    background: rgba(69, 251, 157, 0.1);
    color: var(--mint);
    border: 1px solid rgba(69, 251, 157, 0.2);
}

.ticket-item-type.question {
    background: rgba(95, 179, 255, 0.1);
    color: #5fb3ff;
    border: 1px solid rgba(95, 179, 255, 0.2);
}

.ticket-item-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray-text);
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--gray-text);
    text-align: center;
    padding: 40px;
}

.chat-empty-state i {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(20, 20, 20, 0.4);
}

.chat-header-info h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.chat-header-info span {
    font-size: 0.8rem;
    color: var(--gray-text);
}

.chat-messages-area {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages-area::-webkit-scrollbar {
    width: 6px;
}
.chat-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message-wrapper.outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-wrapper.incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-meta {
    font-size: 0.75rem;
    color: var(--gray-text);
    margin-bottom: 5px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.message-role-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.message-role-tag.admin {
    background: rgba(255, 95, 95, 0.15);
    color: #ff5f5f;
    border: 1px solid rgba(255, 95, 95, 0.3);
}

.message-role-tag.owner {
    background: rgba(69, 251, 157, 0.15);
    color: var(--mint);
    border: 1px solid rgba(69, 251, 157, 0.3);
}

.message-bubble {
    padding: 15px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.message-wrapper.outgoing .message-bubble {
    background: rgba(148, 255, 219, 0.1);
    border: 1px solid rgba(148, 255, 219, 0.2);
    color: white;
    border-top-right-radius: 0;
}

.message-wrapper.incoming .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    border-top-left-radius: 0;
}

.chat-input-area {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    background: rgba(20, 20, 20, 0.4);
}

.chat-input-form {
    display: flex;
    gap: 15px;
    align-items: center;
}

.chat-input-form input {
    flex: 1;
    margin-bottom: 0;
}

.chat-input-form button {
    flex-shrink: 0;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 2px solid var(--mint);
    background: transparent;
    color: var(--mint);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: 0.3s;
    font-size: 1.1rem;
}

.chat-input-form button:hover {
    background: var(--mint);
    color: black;
    box-shadow: 0 0 15px var(--mint);
}

