/* ============================================
   WhatsApp Event Assistant — Design System
   Dark Theme + WhatsApp Palette
   ============================================ */

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

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0B141A;
    --bg-secondary: #111B21;
    --bg-surface: #1F2C34;
    --bg-surface-hover: #2A3942;
    --bg-card: rgba(31, 44, 52, 0.85);
    --bg-input: #2A3942;
    --bg-sidebar: #111B21;

    --text-primary: #E9EDEF;
    --text-secondary: #8696A0;
    --text-muted: #667781;
    --text-inverse: #111B21;

    --accent-primary: #00A884;
    --accent-primary-hover: #06CF9C;
    --accent-secondary: #25D366;
    --accent-danger: #EA4335;
    --accent-danger-hover: #FF6B5B;
    --accent-warning: #FFB020;
    --accent-info: #53BDEB;

    --border-color: rgba(134, 150, 160, 0.15);
    --border-color-hover: rgba(134, 150, 160, 0.3);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 168, 132, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 260px;
    --header-height: 64px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface-hover);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   LAYOUT: Sidebar + Main
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3);
}

.sidebar-brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.sidebar-link:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(0, 168, 132, 0.12);
    color: var(--accent-primary);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-surface);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-info));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

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

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.page-header {
    padding: 24px 32px 0;
}

.page-header h1 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.page-body {
    padding: 24px 32px 40px;
}

/* ============================================
   COMPONENTS: Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(0, 168, 132, 0.25);
}

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

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card-icon.green {
    background: rgba(0, 168, 132, 0.15);
    color: var(--accent-primary);
}

.stat-card-icon.blue {
    background: rgba(83, 189, 235, 0.15);
    color: var(--accent-info);
}

.stat-card-icon.red {
    background: rgba(234, 67, 53, 0.15);
    color: var(--accent-danger);
}

.stat-card-icon.yellow {
    background: rgba(255, 176, 32, 0.15);
    color: var(--accent-warning);
}

.stat-card-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.stat-card-change {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
}

/* ============================================
   COMPONENTS: Tables
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-surface);
}

th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 0.88rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}

tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-surface-hover);
}

/* ============================================
   COMPONENTS: Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-open {
    background: rgba(234, 67, 53, 0.15);
    color: var(--accent-danger);
}

.badge-inprogress {
    background: rgba(255, 176, 32, 0.15);
    color: var(--accent-warning);
}

.badge-resolved {
    background: rgba(0, 168, 132, 0.15);
    color: var(--accent-primary);
}

.badge-closed {
    background: rgba(134, 150, 160, 0.15);
    color: var(--text-muted);
}

.badge-low { background: rgba(83, 189, 235, 0.15); color: var(--accent-info); }
.badge-medium { background: rgba(255, 176, 32, 0.15); color: var(--accent-warning); }
.badge-high { background: rgba(234, 67, 53, 0.15); color: var(--accent-danger); }

.badge-active { background: rgba(0, 168, 132, 0.15); color: var(--accent-primary); }
.badge-inactive { background: rgba(134, 150, 160, 0.15); color: var(--text-muted); }

/* ============================================
   COMPONENTS: Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #00C49A);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-primary-hover), #2BEDA8);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 168, 132, 0.4);
    color: white;
}

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

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(234, 67, 53, 0.15);
    color: var(--accent-danger);
    border: 1px solid rgba(234, 67, 53, 0.2);
}

.btn-danger:hover {
    background: var(--accent-danger);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

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

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238696A0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

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

.validation-message {
    color: var(--accent-danger);
    font-size: 0.78rem;
    margin-top: 4px;
}

/* ============================================
   COMPONENTS: Chat View (WhatsApp Style)
   ============================================ */
.chat-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-header {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.chat-contact-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-contact-phone {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(0, 168, 132, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(83, 189, 235, 0.03) 0%, transparent 50%);
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.5;
    position: relative;
    animation: fadeInUp 0.3s ease;
}

.chat-bubble.incoming {
    background: var(--bg-surface);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
    background: rgba(0, 168, 132, 0.18);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.outgoing.ai {
    border-left: 3px solid var(--accent-info);
}

.chat-bubble-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.chat-bubble-ai-tag {
    font-size: 0.6rem;
    color: var(--accent-info);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-input-area {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area .form-control {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
}

.chat-input-area .btn {
    height: 42px;
    width: 42px;
    padding: 0;
    border-radius: 50%;
}

/* ============================================
   COMPONENTS: Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   COMPONENTS: Filters
   ============================================ */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}

.filter-bar .form-control {
    width: auto;
    min-width: 160px;
}

/* ============================================
   PAGE: Login
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle at 30% 20%, rgba(0, 168, 132, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(37, 211, 102, 0.06) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(0, 168, 132, 0.3);
}

.login-logo h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-error {
    background: rgba(234, 67, 53, 0.1);
    border: 1px solid rgba(234, 67, 53, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
    color: var(--accent-danger);
    font-size: 0.85rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

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

.animate-slide-in {
    animation: slideInRight 0.4s ease;
}

.stat-card {
    animation: fadeInUp 0.5s ease backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

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

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

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

    .page-header,
    .page-body {
        padding-left: 16px;
        padding-right: 16px;
    }

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

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

    .chat-bubble {
        max-width: 90%;
    }

    .mobile-menu-btn {
        display: block !important;
    }
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ---- Action Links ---- */
.action-links {
    display: flex;
    gap: 8px;
}

.action-links a,
.action-links button {
    font-size: 0.8rem;
}

/* ---- Details Page ---- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.detail-item span {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ---- Overlay for mobile sidebar ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Ticket Info Card ---- */
.ticket-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.ticket-info-item {
    padding: 12px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

.ticket-info-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ticket-info-item span {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ---- Chart Container ---- */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}