:root {
    --primary-color: #b794f6;
    /* Light Purple */
    --primary-hover: #a782f4;
    --secondary-color: #64748b;
    --background-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --card-shadow: none;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: var(--transition);
}

.sidebar-toggle-btn:hover {
    background-color: #f3f4f6;
    color: var(--primary-color);
}

/* Collapsed States */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .sidebar-header h2 span {
    margin: 0;
}

/* Collapsed header layout already centered by justify-content: center */

/* If we want to hide the logo entirely and only show toggle when collapsed */
.sidebar.collapsed h2 {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}

.sidebar.collapsed .nav-item span {
    margin: 0;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #fff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}
@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.nav-item {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: #f9fafb;
    color: var(--text-color);
}

.nav-item.active {
    background-color: #f3eeff;
    /* Purple 100-like */
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    min-height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.text-center {
    text-align: center !important;
}

/* Views */
.view {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

#view-subscribers {
    display: none;
    /* Controlled by app.js */
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 0;
    /* Removing padding for edge-to-edge layout if preferred, or keep it */
}

#view-subscribers .content-split {
    padding: 1.5rem;
    height: 100%;
}

/* Cards */
.card {
    background-color: var(--surface-color);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    transition: none;
}

.product-card {
    height: 100%;
}

.product-card-price-container {
    margin-top: auto;
    padding-top: 1.5rem;
    /* Standard title space */
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    /* Standard space between sections */
}

.metric-card h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    /* Standard title space */
    text-transform: uppercase;
    text-align: left;
}

.metric-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
}

.metric-trend,
.metric-badge-container {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center badges/trends */
    min-height: 1.5rem;
    /* Reserve space for trend or badge */
}

.metric-trend.positive {
    color: var(--success-color);
}

.metric-trend.negative {
    color: var(--danger-color);
}

/* Buttons */
.btn {
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

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

.btn-secondary:hover {
    background-color: #f9fafb;
}

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

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: #f3f4f6;
    color: var(--text-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.full-width {
    width: 100%;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.data-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:not(.no-hover):hover {
    background-color: #f9fafb;
    cursor: pointer;
}

.data-table tr.selected {
    background-color: #f3eeff;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.status-active {
    background-color: #d1fae5;
    color: #065f46;
}

.status-expired {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-cancelled {
    background-color: rgba(0, 0, 0, 0.3);
    color: #ffffff;
}



/* Actions Column — hidden by default, revealed via show-actions class */
#subscribers-table .actions-header,
#subscribers-table td:last-child {
    max-width: 0;
    width: 0;
    opacity: 0;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow: hidden;
    white-space: nowrap;
    border-bottom: 1px solid transparent;
    transition: max-width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s ease-out,
        padding 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#subscribers-table.show-actions .actions-header,
#subscribers-table.show-actions td:last-child {
    max-width: 140px;
    width: 140px;
    opacity: 1;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    border-bottom: 1px solid var(--border-color);
}

/* Actions Slide Animation for Buttons */
.row-actions-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.row-actions-container.show {
    opacity: 1;
    transform: translateX(0);
}

.btn-edit-sub,
.btn-delete-sub {
    transition: transform 0.2s ease-out, background-color 0.2s;
}

.btn-edit-sub:hover,
.btn-delete-sub:hover {
    transform: none;
}

/* Layout Split */
.content-split {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.left-panel {
    flex: 55;
    overflow-y: auto;
}

/* Forms */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.full-width-iti {
    width: 100%;
}

.iti {
    --iti-hover-bg: rgba(99, 102, 241, 0.05);
}

.iti__country-list {
    border-radius: 0.5rem;
    box-shadow: none;
    border: 1px solid var(--border-color);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(2px);
}

.modal {
    background-color: white;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    /* Limit height */
    padding: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    flex-shrink: 0;
    padding: 1.5rem;
    /* Standard card space */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal>form,
.modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    /* Enable vertical scroll */
    flex: 1;
}

.modal-footer {
    padding: 1.5rem;
    /* Standard card space */
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    flex-shrink: 0;
}

/* Product Modal Wide Layout */
.product-modal-wide {
    max-width: 800px;
    flex-direction: row;
    height: 750px;
    align-items: stretch;
}

.modal-col-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 380px;
    border-right: 1px solid var(--border-color);
    height: auto;
}

.product-modal-wide .modal-col-form form,
.product-modal-wide .modal-body {
    flex: initial;
}

.modal-col-simulator {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f0f2f5;
    min-width: 380px;
    max-height: 100%;
}

.product-modal-wide .simulator-body {
    flex: 1;
}

.simulator-header {
    background-color: #f0f2f5;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.simulator-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.simulator-header-info .material-icons-outlined {
    font-size: 2rem;
    color: #128c7e;
    background: #fff;
    border-radius: 50%;
    padding: 4px;
}

.simulator-header-text {
    display: flex;
    flex-direction: column;
}

.simulator-header-text strong {
    font-size: 1rem;
    color: var(--text-color);
}

.simulator-header-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.simulator-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #e5ddd5;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
}

.simulator-body .timeline {
    background: transparent;
    border: none;
    padding: 0;
    max-height: none;
}

/* Subscriber Details Panel Animation (Ultra Smooth) */
.right-panel {
    flex: 45;
    display: none !important;
    flex-direction: column;
    gap: 1.5rem;
    overflow: hidden;
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1),
        transform 1s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
    min-height: 0;
}

.right-panel.show {
    display: flex !important;
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
    height: auto;
    max-height: 100%;
}

/* Panel Card - Single card with tabs */
.panel-card {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    background-color: var(--surface-color);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.panel-header {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: white;
    z-index: 10;
    gap: 0.75rem;
}

.panel-header-top {
    display: flex;
    align-items: center;
    justify-content: center; /* Name centered */
    width: 100%;
    position: relative;
    padding: 0.25rem 0;
}

.subscriber-info-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-width: 0;
    /* This will keep the name horizontally centered */
}

.subscriber-info-header .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.subscriber-info-header .sub-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

.panel-header-top .btn-icon {
    position: absolute;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #5f6368;
    transition: background-color 0.2s, color 0.2s;
    background: transparent;
}

.panel-header-top .btn-icon:hover {
    background-color: #f1f3f4; /* Subtle shading requested */
    color: #202124;
}

.panel-tabs {
    display: flex;
    background: #f0f1f5;
    padding: 0.2rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    gap: 0.15rem;
    align-self: center; /* Center the tabs selector in its row */
}

.panel-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 2rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.panel-tab-btn:hover {
    color: var(--text-color);
}

.panel-tab-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}


/* Panel Tabs Slider for Horizontal Motion */
.panel-tabs-slider {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 400%; /* 4 tabs * 100% */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Tab Content - Adjusted for Slider */
.tab-content {
    display: flex !important; /* Always flex to allow being part of the slider */
    flex-direction: column;
    min-width: 25%; /* 1/4 of the 400% width container */
    max-width: 25%;
    flex: 1;
    min-height: 0;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.tab-content.active {
    opacity: 1;
}

/* Details card inner (inside detail tab) */
.details-card-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
}

.details-card-inner .card-body {
    padding: 1.5rem;
}

.details-card-inner .card-footer {
    padding: 1rem 1.5rem 1.5rem;
    /* Space on sides and base */
    margin-top: auto;
    /* Push to bottom */
}

/* Timeline card inner (inside history tab) */
.timeline-card-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 1.5rem;
    overflow: hidden; /* Prevent nested scrolling conflict */
}

/* WhatsApp Mobile Proportion for Messages Tab */
#tab-messages .timeline-card-inner {
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem 0; /* Vertical padding only, let internal elements handle horizontal */
}

/* Legacy .details-card (keep for hover override) */
.details-card:hover {
    box-shadow: none;
}


/* Utilities */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.actions-bar input,
.actions-bar select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: var(--surface-color);
    transition: var(--transition);
    color: var(--text-color);
}

.actions-bar input {
    flex: 1;
}

.actions-bar select {
    padding-right: 2.5rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    min-width: 140px;
}

.actions-bar input:focus,
.actions-bar select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.actions-bar select:hover {
    border-color: var(--text-muted);
}

/* Grid for Products */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.product-card {
    position: relative;
    overflow: hidden;
    text-align: left;
}

.product-card-actions-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    z-index: 5;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease-out;
    opacity: 0;
}

.product-card.show-actions .product-card-actions-container {
    transform: translateY(0);
    opacity: 1;
}

/* WhatsApp Chat Header */
.wa-chat-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: #f0f2f5;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 0.8rem 0.8rem 0 0;
    gap: 12px;
    flex-shrink: 0;
}

.wa-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.wa-header-info {
    display: flex;
    flex-direction: column;
}

.wa-header-name {
    font-size: 16px;
    font-weight: 500;
    color: #111b21;
}

.wa-header-status {
    font-size: 13px;
    color: #667781;
}

/* WhatsApp Style Timeline */
.timeline {
    list-style: none;
    padding: 1rem 1rem 1.5rem;
    border: 1px solid var(--border-color);
    border-top: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: #e5ddd5;
    /* WhatsApp background color */
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    border-radius: 0 0 0.8rem 0.8rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.timeline-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    gap: 0.75rem;
}

.date-header {
    position: sticky;
    top: 0.5rem; /* Small offset for better look */
    z-index: 10;
    pointer-events: none;
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 1rem 0;
}

.date-header span {
    background-color: rgba(225, 245, 254, 0.9);
    color: #54656f;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
}

.scroll-bottom-btn {
    position: absolute;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: white;
    border: none;
    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.06), 0 2px 5px 0 rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #54656f;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 15;
}

.scroll-bottom-btn span {
    font-size: 20px;
}

.scroll-bottom-btn.show {
    opacity: 1;
    transform: scale(1);
}

.scroll-bottom-btn:hover {
    background-color: #f0f2f5;
}

.timeline-item {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    position: relative;
    font-size: 0.875rem;
    line-height: 1.4;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Outbound messages (right) */
.timeline-item.outbound {
    align-self: flex-end;
    background-color: #dcf8c6;
    border-top-right-radius: 0;
    margin-right: 8px;
}

/* Inbound messages (left) */
.timeline-item.inbound {
    align-self: flex-start;
    background-color: #ffffff;
    border-top-left-radius: 0;
    margin-left: 8px;
}

.timeline-item .msg-content {
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    color: #303030;
}

.timeline-item .msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.timeline-item .msg-time {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.45);
}

.timeline-item .msg-status {
    display: flex;
    align-items: center;
}

.timeline-item .msg-status span {
    font-size: 18px;
    color: #8696a0;
    /* WA Grey */
}

.timeline-item .msg-status span.material-icons-outlined {
    font-size: 18px;
}

.timeline-item .msg-status span.status-read {
    color: #53bdeb !important; /* WhatsApp blue for read receipts */
}

.timeline-item .msg-status span.status-failed {
    color: #ff4d4f !important; /* Red for failed messages */
}

/* Bubble Tails */
.timeline-item.outbound::after {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #dcf8c6;
    border-left: 0;
}

.timeline-item.inbound::after {
    content: "";
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #ffffff;
    border-right: 0;
}

/* QR Placeholder */
.qr-placeholder img {
    width: 100%;
    height: auto;
    max-width: 200px;
    display: block;
    margin: 0 auto;
}

/* Metric Card Header */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    min-height: 3rem;
    position: relative;
    /* For absolute help icon if needed, or just keep it in flow */
}

.card-header-flex h3 {
    margin-bottom: 0;
    text-align: left;
}

.help-icon {
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    margin-left: 0.5rem;
    /* Space from title */
}

.help-icon:hover {
    color: var(--primary-color);
}

/* Tooltip */
.metric-card {
    position: relative;
    cursor: grab;
    transition: none;
    text-align: center;
}

.metric-card:active {
    cursor: grabbing;
}

.metric-card:hover {
    transform: none;
    box-shadow: none;
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light) !important;
    border: 2px dashed var(--primary-color) !important;
}

.sortable-chosen {
    box-shadow: none !important;
}


.tooltip {
    display: none;
    position: absolute;
    top: 3rem;
    right: 1.5rem;
    left: 1.5rem;
    background-color: #1f2937;
    /* Dark Gray 800 */
    color: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.4;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    right: 10px;
    /* Adjust based on icon position */
    width: 10px;
    height: 10px;
    background-color: #1f2937;
    transform: rotate(45deg);
}

.tooltip.show {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

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

/* Apple Style Toggle Switch */
.apple-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    vertical-align: middle;
}

.apple-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.apple-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e9e9eb;
    transition: .4s;
    border-radius: 24px;
}

.apple-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.apple-slider {
    background-color: #34c759;
    /* Apple Green */
}

input:focus+.apple-slider {
    box-shadow: 0 0 1px #34c759;
}

input:checked+.apple-slider:before {
    transform: translateX(18px);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ===== Modal de Confirmación Global ===== */
.confirm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.confirm-modal-overlay.active {
    display: flex;
}

.confirm-modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    /* Standard spacing */
    max-width: 420px;
    width: 90%;
    box-shadow: none;
    animation: confirmBoxIn 0.2s ease-out both;
}

@keyframes confirmBoxIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.confirm-modal-box p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
    margin: 0 0 1.5rem;
    line-height: 1.5;
    text-align: center;
}

.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.confirm-modal-actions .btn-secondary {
    background: #f0f1f5;
    color: #555;
    border: none;
    padding: 0.55rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.confirm-modal-actions .btn-secondary:hover {
    background: #e2e4ea;
}

.confirm-modal-actions .btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0.55rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.confirm-modal-actions .btn-danger:hover {
    background: #dc2626;
}

/* ── CSV Column Mapping Modal ── */
.csv-mapping-box {
    max-width: 640px;
    width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
}

.csv-mapping-table-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 0;
}

.csv-mapping-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.csv-mapping-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.csv-mapping-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    vertical-align: middle;
}

.csv-mapping-field-name {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.csv-mapping-field-name .mapping-required {
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.csv-mapping-table select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    background: #fff;
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.15s;
}

.csv-mapping-table select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.csv-mapping-table select.unmapped {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.05);
}

.csv-mapping-preview {
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csv-mapping-preview .preview-row {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.csv-mapping-box .confirm-modal-actions {
    margin-top: 0;
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: #fff;
}

/* ── Import Results Modal ── */
.import-results-box {
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent double scrollbars */
    padding-bottom: 0;
    /* Action block handles padding */
}

.import-summary-cards {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.import-result-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}

.import-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.import-result-card.active {
    border-color: currentColor;
}

.import-card-created {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.import-card-edited {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.import-card-skipped {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.import-card-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.import-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.import-result-card .material-icons-outlined {
    font-size: 1.25rem;
}

.import-details-container {
    flex: 1;
    /* Grow to fill space */
    min-height: 0;
    /* Critical for flex scroll */
    max-height: 400px;
    /* Limit scroll area */
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.import-details-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.import-details-list li {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.import-details-list li:last-child {
    border-bottom: none;
}

.import-detail-name {
    font-weight: 500;
    color: var(--text-color);
}

.import-detail-reason {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    max-width: 60%;
}

.import-results-box .confirm-modal-actions {
    margin-top: 0;
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: #fff;
    z-index: 10;
}

/* ── Multi-subscription UI ── */

/* Badge: active subscription count on subscriber row */
.subs-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    line-height: 1;
}

/* Subscription item card inside detail panel */
.subscription-item {
    display: grid;
    grid-template-columns: 1fr 80px;
    grid-template-rows: auto auto;
    align-items: center;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    gap: 0.25rem 1rem;
    transition: all 0.2s ease;
}

/* .subscription-item:hover removed per user request */

.subscription-item .sub-name {
    grid-column: 1;
    grid-row: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.subscription-item .sub-status {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subscription-item .sub-info {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.subscription-item .sub-toggle {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subscription-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

/* Smaller apple toggle variant for subscription list */
.apple-switch-sm {
    width: 34px;
    height: 19px;
}

.apple-switch-sm .apple-slider:before {
    height: 15px;
    width: 15px;
    left: 2px;
    bottom: 2px;
}

/* Collapsible Cards */
.collapsible-card {
    transition: all 0.3s ease;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
    /* Removed padding-bottom: 1.5rem to avoid doubling with .card-header-flex margin */
}

.collapsible-header:hover {
    opacity: 1;
}

.collapsible-card.collapsed .collapsible-content {
    display: none;
}

.collapse-icon {
    transition: transform 0.3s ease;
}

.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* Product Checkbox List */
.product-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.product-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    background: white;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.product-checkbox-item:hover {
    border-color: var(--border-color);
}

.product-checkbox-item input {
    margin: 0;
    cursor: pointer;
}

.product-checkbox-item input:focus {
    outline: none;
    box-shadow: none;
}

.analytics-row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Restored to standard gap */
}

/* Sortable Styles */
.sortable-ghost {
    opacity: 0.4;
    background: #e5e7eb !important;
}

.sortable-chosen {
    cursor: grabbing !important;
    box-shadow: none;
}

.collapsible-header {
    cursor: grab;
}

.collapsible-header:active {
    cursor: grabbing;
}

/* Subscription Row Actions */
.subscription-item {
    position: relative;
    overflow: hidden;
}

.sub-row-actions-container {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) translateX(100%);
    background: var(--primary-color);
    padding: 0 1rem;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: none;
    z-index: 5;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease-out;
    opacity: 0;
}

.sub-row-actions-container .btn-icon,
.sub-row-actions-container .material-icons-outlined {
    color: white !important;
}

.sub-row-actions-container .btn-icon:hover {
    background-color: transparent !important;
    color: white !important;
}

.subscription-item.show-actions .sub-row-actions-container {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

/* Skeleton Loader Styles */
.skeleton {
    display: none;
    background: #e2e8f0;
    background: linear-gradient(110deg, #eceff1 8%, #f5f5f5 18%, #eceff1 33%);
    border-radius: 5px;
    background-size: 200% 100%;
    animation: 1.5s shine linear infinite;
}

@keyframes shine {
    to {
        background-position-x: -200%;
    }
}

.skeleton-text {
    width: 100%;
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-title {
    width: 60%;
    height: 18px;
    margin-bottom: 12px;
}

.skeleton-metric {
    width: 80%;
    height: 32px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-rect {
    width: 100%;
    height: 200px;
}

/* Hide content when skeleton is present */
.is-loading>*:not(.skeleton):not(#wa-chat-header-skeleton):not(#wa-chat-header):not(.activity-stream):not(.timeline):not(.payments-card-inner):not(#subscriptions-section):not(.subscriptions-header):not(#subscriptions-list):not(#payments-history-container) {
    display: none !important;
}

/* Ensure timeline and subscription content shows only skeletons when loading */
.is-loading .timeline>*:not(.skeleton),
.is-loading #subscriptions-section>*:not(.skeleton):not(#subscriptions-list):not(.subscriptions-header),
.is-loading#subscriptions-section>*:not(.skeleton):not(#subscriptions-list):not(.subscriptions-header),
.is-loading #subscriptions-list>*:not(.skeleton) {
    display: none !important;
}

.skeleton-row-sub td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
}

.skeleton-row {
    width: 100%;
    height: 40px;
    margin-bottom: 8px;
}

.skeleton-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.is-loading .skeleton {
    display: block !important;
}

/* Global Loading Bar */
.global-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--primary-color);
    z-index: 10001;
    transition: width 0.3s ease-out, opacity 0.3s;
    pointer-events: none;
    opacity: 0;
}

.global-loading-bar.active {
    opacity: 1;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- SSE Connection Status Indicator --- */
.sse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease;
    margin-right: 8px;
    flex-shrink: 0;
}

.sse-connected {
    background-color: var(--success-color);
    box-shadow: 0 0 4px var(--success-color);
    animation: sse-pulse 2s infinite;
}

.sse-disconnected {
    background-color: var(--danger-color);
    box-shadow: 0 0 4px var(--danger-color);
}

@keyframes sse-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========================================
   AGENTS SECTION — Specialist Cards & Feed
   ======================================== */

/* Grid of Agent Cards */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.agent-card {
    padding: 1.5rem;
    /* Standard card space */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.agent-card:hover {
    transform: none;
    box-shadow: none;
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    /* Standard title space */
}

/* Agent Avatar — Color-coded by specialty */
.agent-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.agent-avatar .material-icons-outlined {
    font-size: 24px;
    color: white;
}

.agent-avatar--cobranzas {
    background: linear-gradient(135deg, #b794f6, #cbb2ff);
    box-shadow: none;
}

.agent-avatar--bienvenida {
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: none;
}

.agent-avatar--retencion {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    box-shadow: none;
}

.agent-avatar--conciliador {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    box-shadow: none;
}

/* Agent status dot */
.agent-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid var(--surface-color);
}

.agent-status-dot.online {
    background-color: var(--success-color);
    animation: agent-pulse 2.5s infinite;
}

.agent-status-dot.offline {
    background-color: var(--text-muted);
}

@keyframes agent-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
    }
}

.agent-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
}

.agent-role {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Agent Card Stats */
.agent-card-stats {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 0;
    /* More balanced padding */
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    /* Standard title space */
}

.agent-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.agent-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
}

.agent-stat-errors {
    color: var(--danger-color);
}

.agent-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* Agent Card Footer */
.agent-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.agent-last-activity {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   ACTIVITY STREAM — Live Feed
   ======================================== */

.activity-stream-card {
    /* Uses standard .card padding (1.5rem) */
    overflow: hidden;
}

.activity-stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.activity-stream-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.activity-stream-live-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-color);
    background-color: var(--border-color);
    opacity: 0.9;
    padding: 2px 10px;
    border-radius: 9999px;
    letter-spacing: 0.02em;
    animation: live-pulse-notoria 1.5s infinite ease-in-out;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 0;
    /* Clear previous margin */
}

.live-dot {
    color: #10b981;
    /* Green */
    margin-right: 4px;
    font-size: 0.8rem;
}

@keyframes live-pulse-notoria {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.3;
        transform: scale(0.95);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.activity-stream {
    max-height: 440px;
    overflow-y: auto;
    padding: 0;
    /* List items align with the header thanks to card padding */
}

.activity-stream-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    gap: 0.5rem;
}

.activity-stream-empty p {
    font-size: 0.85rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    gap: 0.5rem;
    text-align: center;
    width: 100%;
    min-height: 250px;
}

/* For grid containers, make the empty state span all columns */
.grid-container .empty-state {
    grid-column: 1 / -1;
}


.empty-state .material-icons-outlined {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 0.25rem;
}

.empty-state p {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.empty-state .empty-hint {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.6;
    margin-top: 2px;
}

/* Timeline Empty State */
.timeline-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    gap: 0.5rem;
    text-align: center;
    list-style: none;
    width: 100%;
    min-height: 250px;
}

.timeline-empty-state .material-icons-outlined {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 0.25rem;
}

.timeline-empty-state p {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.timeline-empty-state .empty-hint {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.6;
    margin-top: 0.25rem;
}



/* Individual activity item */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    /* Align with header using card padding */
    border-bottom: 1px solid var(--border-color);
    transition: none;
    animation: activity-fade-in 0.4s ease-out;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background-color: transparent;
}

@keyframes activity-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Activity item icon (mini avatar) */
.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon .material-icons-outlined {
    font-size: 16px;
    color: white;
}

.activity-icon--cobranzas {
    background: linear-gradient(135deg, #b794f6, #cbb2ff);
}

.activity-icon--bienvenida {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.activity-icon--retencion {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.activity-icon--conciliador {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

/* Activity text content */
.activity-text {
    flex: 1;
    min-width: 0;
}

.activity-action {
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 500;
}

.activity-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.activity-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Error status highlight */
.activity-item.activity-error {
    background-color: rgba(239, 68, 68, 0.04);
}

.activity-item.activity-error .activity-action {
    color: var(--danger-color);
}

.activity-item.activity-error .activity-icon {
    background: linear-gradient(135deg, #ef4444, #f87171) !important;
}

/* Product Filter Chips */
.product-chip-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.product-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 2rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.product-chip:hover {
    background-color: var(--background-color);
}

.product-chip.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.product-chip input[type="checkbox"] {
    display: none;
}

.filter-preset-btn {
    border-radius: 2rem;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
}

.filter-preset-btn.active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}
/* Custom Flatpickr Theme - Premium Look */
.flatpickr-calendar {
    background: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    font-family: 'Inter', sans-serif;
    width: 315px !important; /* Slightly smaller for better fit */
    display: flex;
    flex-direction: column;
    z-index: 10002 !important; /* Ensure it stays above everything */
    overflow: visible !important;
}

.flatpickr-innerContainer {
    width: 100% !important;
}

.flatpickr-days {
    width: 100% !important;
}

.dayContainer {
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
    gap: 0;
}

.flatpickr-day.selected, 
.flatpickr-day.startRange, 
.flatpickr-day.endRange, 
.flatpickr-day.selected.inRange, 
.flatpickr-day.startRange.inRange, 
.flatpickr-day.endRange.inRange, 
.flatpickr-day.selected:focus, 
.flatpickr-day.startRange:focus, 
.flatpickr-day.endRange:focus, 
.flatpickr-day.selected:hover, 
.flatpickr-day.startRange:hover, 
.flatpickr-day.endRange:hover, 
.flatpickr-day.selected.prevMonthDay, 
.flatpickr-day.startRange.prevMonthDay, 
.flatpickr-day.endRange.prevMonthDay, 
.flatpickr-day.selected.nextMonthDay, 
.flatpickr-day.startRange.nextMonthDay, 
.flatpickr-day.endRange.nextMonthDay {
    background: #b794f6 !important; /* Premium purple */
    border-color: #b794f6 !important;
    color: #fff !important;
    border-radius: 50% !important;
    font-weight: 600;
}

.flatpickr-months .flatpickr-month {
    color: var(--text-color);
    fill: var(--text-color);
    height: 40px;
}

.flatpickr-current-month {
    font-size: 1.1rem;
    font-weight: 500;
}

.flatpickr-monthDropdown-months {
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
    font-weight: 700 !important;
    color: #1f2937 !important;
    font-size: 1.1rem !important;
}

.flatpickr-current-month .numInputWrapper {
    width: 7ch;
}

.flatpickr-current-month input.cur-year {
    font-weight: 700 !important;
    color: #1f2937 !important;
}

.flatpickr-weekday {
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.flatpickr-day {
    border-radius: 50% !important;
    height: 38px !important;
    width: 38px !important;
    line-height: 38px !important;
    margin: 2px !important;
    font-size: 0.9rem;
    color: #334155;
    flex-basis: 38px !important;
}

.flatpickr-day.today {
    border-color: #4facfe !important;
    color: #4facfe;
}

.flatpickr-day.today:hover {
    background: #4facfe !important;
    color: #fff !important;
}

.flatpickr-day:hover {
    background: #f1f5f9 !important;
}

.flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover {
    color: #cbd5e1 !important;
}

/* Custom Input Styling for Date Pickers */
.income-date-input {
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 0.6rem 1rem !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    color: #1e293b !important;
    background-color: #fff !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.income-date-input:focus {
    border-color: #4facfe !important;
    box-shadow: 0 0 0 4px rgba(79, 172, 254, 0.1) !important;
    background-color: #fff !important;
}

.income-date-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.4rem;
}

/* Subscriber History Styles - Interleaved Timeline */
#history-timeline {
    padding: 0;
    list-style: none;
    margin: 0;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
    position: relative;
    /* Removed block/visible to allow base .timeline overflow-y: auto to work */
    /* display: block; */
    /* overflow: visible; */
    flex: 1;
    min-height: 0;
}

/* Vertical Center Line - Darker and ensured to span */
#history-timeline::before {
    display: none; /* Removed global line in favor of item-based segments */
}

#history-timeline .timeline-date-separator {
    width: 100%;
    text-align: center;
    position: sticky;
    top: 0.75rem;
    z-index: 10;
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.history-date-section {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* Separators don't need line segments anymore to prevent overlap/glitches */
#history-timeline .timeline-date-separator::before {
    display: none !important;
}

#history-timeline .timeline-date-separator:first-child {
    margin-top: 0 !important;
}

#history-timeline .timeline-date-separator span {
    position: relative;
    z-index: 5; /* Higher priority to cover any line */
    background: white;
    color: #64748b;
    padding: 0.5rem 1.25rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

#history-timeline .timeline-item {
    width: 50%;
    position: relative;
    margin-bottom: 2.5rem;
    z-index: 2;
    transition: all 0.3s ease;
    box-shadow: none !important;
    border: none !important;
    padding: 0; 
    background: transparent !important;
    max-width: none !important;
}

/* Central Line segments on each item */
#history-timeline .timeline-item::before {
    content: '';
    position: absolute;
    width: 2px;
    background: #cbd5e1;
    top: -2.5rem; /* Cover gap from previous item */
    bottom: -2.5rem; /* Cover gap to next item */
    z-index: 1;
}

#history-timeline .timeline-item.left-side::before {
    right: -1px;
}

#history-timeline .timeline-item.right-side::before {
    left: -1px;
}

/* Start the line at the first icon */
#history-timeline .timeline-item:first-of-type::before {
    top: 3.25rem;
}

/* End the line at the last icon */
#history-timeline .timeline-item:last-of-type::before {
    bottom: auto;
    height: 3.25rem;
}

/* Left Side Items */
#history-timeline .timeline-item.left-side {
    left: 0;
    padding-right: 3rem;
    text-align: right;
}

/* Right Side Items */
#history-timeline .timeline-item.right-side {
    left: 50%;
    padding-left: 3rem;
    text-align: left;
}

/* Icon on the center line */
#history-timeline .timeline-icon {
    position: absolute;
    top: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 6px white, 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10;
    border: 1px solid #e2e8f0;
}

#history-timeline .timeline-item.left-side .timeline-icon {
    right: -20px;
}

#history-timeline .timeline-item.right-side .timeline-icon {
    left: -20px;
}

#history-timeline .timeline-icon span {
    font-size: 22px;
}

/* Premium Content Card (Bubble Style) */
#history-timeline .timeline-content {
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 450px;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#history-timeline .timeline-content:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

/* Bubble Arrow */
/* Aligned with the center of the 40px icon (top: 2rem + 20px) */
#history-timeline .timeline-content::after {
    content: '';
    position: absolute;
    top: 3.25rem;
    width: 16px;
    height: 16px;
    background: #f9fafb;
    border: 1px solid #e2e8f0;
    z-index: 1;
}

#history-timeline .timeline-item.left-side .timeline-content::after {
    right: -8px;
    border-left: 0;
    border-bottom: 0;
    transform: translateY(-50%) rotate(45deg);
}

#history-timeline .timeline-item.right-side .timeline-content::after {
    left: -8px;
    border-right: 0;
    border-top: 0;
    transform: translateY(-50%) rotate(45deg);
}

/* Fix hover arrow border */
#history-timeline .timeline-content:hover::after {
    border-color: var(--primary-color);
}

/* Card Header */
#history-timeline .timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

#history-timeline .timeline-title {
    font-weight: 800;
    color: #0f172a;
    font-size: 1.1rem;
    line-height: 1.2;
}

#history-timeline .timeline-time {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    display: none; /* Hidden on desktop, shown on mobile */
}

/* Time positioned on the opposite side of the bubble */
#history-timeline .timeline-time-outer {
    position: absolute;
    top: 3.25rem;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
    z-index: 5;
    display: block;
}

#history-timeline .timeline-item.left-side .timeline-time-outer {
    left: calc(100% + 35px); /* Positioned to the right of central icon */
}

#history-timeline .timeline-item.right-side .timeline-time-outer {
    right: calc(100% + 35px); /* Positioned to the left of central icon */
    text-align: right;
}

/* Product Badge (matches subscription cards) */
#history-timeline .timeline-product {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    color: #475569;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    border: 1px solid #e2e8f0;
}

#history-timeline .timeline-desc {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.6;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    #history-timeline::before {
        display: none !important;
    }
    
    #history-timeline .timeline-item {
        width: 100% !important;
        left: 0 !important;
        padding-left: 80px !important;
        padding-right: 1.5rem !important;
        text-align: left !important;
    }

    /* Standardize line positions for mobile - Always at 40px */
    #history-timeline .timeline-item::before,
    #history-timeline .timeline-item.left-side::before,
    #history-timeline .timeline-item.right-side::before,
    #history-timeline .timeline-date-separator::before {
        left: 40px !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        z-index: 1 !important;
    }

    #history-timeline .timeline-date-separator {
        justify-content: flex-start !important;
        padding-left: 0 !important;
        margin: 1.5rem 0 !important;
    }

    #history-timeline .timeline-date-separator span {
        margin-left: 40px !important;
        transform: translateX(-50%) !important;
        z-index: 10 !important;
        position: relative !important;
    }

    /* Ensure first separator line matches mobile position and doesn't reach up */
    #history-timeline .timeline-date-separator:first-child::before {
        left: 40px !important;
        top: 50% !important;
    }
    
    #history-timeline .timeline-icon {
        left: 20px !important;
        right: auto !important;
    }
    
    #history-timeline .timeline-content {
        max-width: none;
    }
    
    #history-timeline .timeline-content::after {
        left: -8px !important;
        right: auto !important;
        border-right: 0 !important;
        border-top: 0 !important;
        border-left: 1px solid #e2e8f0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        transform: translateY(-50%) rotate(45deg) !important;
    }

    /* Move time back inside for mobile */
    #history-timeline .timeline-time {
        display: block !important;
        margin-top: 0.5rem;
    }

    #history-timeline .timeline-time-outer {
        display: none !important;
    }
}

/* Table responsiveness and scrollability */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.payments-card-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Custom scrollbar for better appearance */
.payments-card-inner::-webkit-scrollbar {
    width: 6px;
}

.payments-card-inner::-webkit-scrollbar-track {
    background: transparent;
}

.payments-card-inner::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.payments-card-inner::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}
/* Payment Mode Badges */
.payment-mode-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: var(--transition);
}

.payment-mode-badge span.material-icons-outlined {
    font-size: 14px;
}

.payment-mode-badge.automatic {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #dbeafe;
}

.payment-mode-badge.manual {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid #d1fae5;
}
