/* ========== Premium Loyalty Admin Theme ========== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-main: #f3f6f9;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: linear-gradient(90deg, rgba(99, 102, 241, 0.2) 0%, transparent 100%);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.05);
    --card-bg: rgba(255, 255, 255, 0.95);

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.stat-value,
.card-title,
.logo-text {
    font-family: 'Outfit', sans-serif;
}

/* ========== App Layout ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 32px 24px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.2));
    animation: float 6s ease-in-out infinite;
}

.logo-text {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-4px);
    }

    100% {
        transform: translateY(0px);
    }
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    margin-bottom: 4px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    border-radius: 0 4px 4px 0;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    transition: transform 0.3s;
}

.nav-item:hover .nav-icon {
    transform: scale(1.15) rotate(5deg);
}

.nav-divider {
    padding: 32px 20px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #475569;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, .05);
}

.logout-btn {
    color: #fca5a5 !important;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 20px -10px rgba(0, 0, 0, 0.03);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    flex: 1;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-name {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 600;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
}

.content-area {
    padding: 32px 40px;
    flex: 1;
}

/* ========== Cards & Grids ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: transparent;
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 40px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    background: linear-gradient(135deg, #0f172a 0%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-icon {
    font-size: 36px;
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-card:hover .stat-icon {
    transform: translateY(-50%) scale(1.15) rotate(-5deg);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
    transition: var(--transition);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.card-body {
    padding: 32px;
}

/* ========== Tables ========== */
.table-responsive {
    overflow-x: auto;
    margin: -1px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 16px 24px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #e2e8f0;
    background: transparent;
}

.data-table td {
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    transition: background 0.2s;
}

.data-table tr {
    transition: transform 0.2s, box-shadow 0.2s;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.23);
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.39);
}

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

.btn-outline:hover {
    border-color: var(--text-muted);
    background: rgba(0, 0, 0, 0.02);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: #f8fafc;
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ========== Search & Filter ========== */
.toolbar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    width: 320px;
    border-radius: 50px;
    padding-left: 20px;
}

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    padding: 24px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 56px 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

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

.login-card h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 12px;
    text-align: center;
    color: #0f172a;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 15px;
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 14px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 50px;
    margin-top: 16px;
}

/* ========== QR Display ========== */
.qr-container {
    text-align: center;
    padding: 32px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: inline-block;
    margin: 0 auto;
}

.qr-container img {
    max-width: 320px;
    border-radius: var(--radius-md);
    border: 16px solid #f8fafc;
}

.qr-status {
    margin-top: 24px;
    font-size: 18px;
    font-weight: 600;
}

/* ========== Chat / Messages ========== */
.chat-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    height: calc(100vh - 160px);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-list {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    background: #fff;
}

.chat-messages {
    overflow-y: auto;
    background: #f8fafc;
    padding: 32px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-main);
}

.chat-item:hover,
.chat-item.active {
    background: #f1f5f9;
    border-left: 4px solid var(--primary);
}

.chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.chat-preview {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.chat-time {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-unread {
    background: var(--danger);
    color: #fff;
    border-radius: 50px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

.message-bubble {
    max-width: 70%;
    padding: 14px 20px;
    border-radius: 20px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.message-in {
    background: #fff;
    border-bottom-left-radius: 4px;
    border-top-left-radius: 20px;
    margin-right: auto;
}

.message-out {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    border-top-right-radius: 20px;
    margin-left: auto;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: block;
    text-align: right;
}

/* ========== JSON Display ========== */
.json-display {
    background: #0f172a;
    color: #38bdf8;
    padding: 24px;
    border-radius: var(--radius-md);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 500px;
    overflow: auto;
    border: 1px solid #1e293b;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 32px;
}

.pagination a,
.pagination span {
    padding: 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    background: #fff;
}

.pagination a:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

/* ========== Alerts ========== */
.alert {
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: var(--danger-bg);
    color: #7f1d1d;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-info {
    background: var(--info-bg);
    color: #1e3a8a;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h2 {
    margin-bottom: 24px;
    font-size: 24px;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px dashed #cbd5e1;
    margin-bottom: 24px;
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
    display: inline-block;
    filter: grayscale(1);
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text-main);
    margin-bottom: 12px;
    font-weight: 700;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 24px;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .top-header {
        padding: 16px 24px;
    }

    .content-area {
        padding: 24px;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chat-list {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 400px;
    }

    .login-card {
        padding: 40px 32px;
        border-radius: var(--radius-md);
    }
}