/* === Component Styles === */

/* Unified control chip styles (buttons/selects) */
.control-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--chip-border, #dfe4ea);
    background: var(--chip-bg, #f9fafc);
    color: var(--chip-fg, #333333);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.control-chip:hover {
    border-color: #c9d2e6;
    box-shadow: 0 2px 6px rgba(16,24,40,0.06);
}

.control-chip:focus,
.control-chip:focus-visible {
    outline: none;
    border-color: #7aa2ff;
    box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.2);
}

.control-chip.primary {
    --chip-bg: #eef3ff;
    --chip-border: #c8d1ff;
    --chip-fg: #223;
}

.control-chip.tertiary {
    --chip-bg: #f9fafc;
    --chip-border: #dfe4ea;
    --chip-fg: #1f2937;
}

select.control-chip {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #888 50%), linear-gradient(135deg, #888 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 28px;
}

select.control-chip:focus {
    outline: none;
}

.control-chip .clock-icon { margin-right: 6px; }

/* Dropdown triggers */
.mode-dropdown .dropdown-trigger,
.dropdown-trigger {
    position: relative;
    padding-right: 26px;
}

.dropdown-trigger::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #666;
}

.dropdown-trigger.open::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Remove caret for bell button which is not a dropdown-trigger */
.nav-notifications > .dropdown-trigger::after { display: none; }

/* Switch pill */
.switch-pill {
    position: relative;
    width: 44px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    background: #e5e7eb;
    cursor: pointer;
    transition: background 160ms ease;
}

.switch-pill::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: transform 160ms ease;
}

.switch-pill[aria-checked="true"] {
    background: #22c55e;
}

.switch-pill[aria-checked="true"]::after {
    transform: translateX(20px);
}

/* Notifications dropdown typography */
.nav-notifications .dropdown-menu .chip-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--light-text-primary);
}

.nav-notifications .dropdown-menu .dropdown-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--light-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Notifications dropdown positioning */
.nav-notifications { position: relative; }
.nav-notifications .dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--light-bg-primary);
    border: 1px solid var(--light-border-primary);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.15);
    z-index: 200;
}
.dropdown-menu[hidden] { display: none !important; }

/* Compact Sidebar Filter Groups */
.sidebar-filters { 
    padding: 8px 10px; 
    border-bottom: 1px solid var(--light-border-primary); 
    background: var(--light-bg-secondary); 
}

.filter-group { 
    padding: 6px 4px; 
    border-bottom: 1px dashed var(--light-border-primary); 
}

.filter-group:last-child { border-bottom: none; }

.filter-group-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 2px 6px; 
}

.filter-group-toggle { 
    display:flex; 
    align-items:center; 
    justify-content: space-between; 
    gap:6px; 
    width:100%; 
    background: transparent; 
    border:none; 
    padding:4px 2px; 
    cursor:pointer; 
    color: var(--light-text-secondary); 
}

.filter-group-toggle .caret { 
    width: 0; 
    height: 0; 
    border-left: 5px solid transparent; 
    border-right: 5px solid transparent; 
    border-top: 6px solid var(--light-text-secondary); 
    transition: transform 0.15s ease; 
    margin-left: 8px; 
}

.filter-group-toggle.open .caret { transform: rotate(180deg); }

.filter-title { 
    font-size: 12px; 
    font-weight: 600; 
}

.filter-header-actions { 
    display:flex; 
    align-items:center; 
    gap:6px; 
}

.filter-reset, .filter-add { 
    border: 1px solid var(--light-border-primary); 
    background: var(--light-bg-primary); 
    color: var(--light-text-secondary); 
    padding: 2px 8px; 
    border-radius: 999px; 
    font-size: 11px; 
    cursor: pointer; 
}

.filter-reset:hover, .filter-add:hover { 
    background: #eef2f7; 
    color: var(--light-text-primary); 
}

.filter-selectall-option { margin: 0; }
.filter-selectall-option input { width: 14px; height: 14px; }

.filter-options { 
    display: none; 
    flex-wrap: wrap; 
    gap: 6px; 
    padding: 6px 6px 2px 6px; 
}

.filter-option { 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    background: transparent; 
    border: none; 
    border-radius: 0; 
    padding: 0; 
    font-size: 12px; 
}

.filter-option input[type="checkbox"] { 
    width: 14px; 
    height: 14px; 
}

.filter-option .delete-status-btn { 
    margin-left: 4px; 
    border: none; 
    background: transparent; 
    color: #9a3b3b; 
    font-size: 16px; 
    line-height: 1; 
    cursor: pointer; 
}

.filter-option .delete-status-btn:hover { 
    color: #c0392b; 
}

.filter-options #addStatusBtn { 
    border: 1px dashed var(--light-border-primary); 
    background: var(--light-bg-primary); 
    color: var(--light-text-secondary); 
    padding: 4px 8px; 
    border-radius: 999px; 
    font-size: 12px; 
    cursor: pointer; 
}

.filter-options #addStatusBtn:hover { 
    background: #eef2f7; 
    color: var(--light-text-primary); 
}

.mode-filter-btn .icon {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
}

.conversation-mode-icon .icon {
    width: 20px;
    height: 20px;
}

.chip-icon .icon {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
}

.dropdown-item .icon {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
    color: #6c757d;
}

/* Button Styles */
.pause-control-form button,
button.tertiary {
    background-color: var(--action-tertiary-bg);
    color: var(--action-tertiary-text);
    border: 1px solid var(--light-border-input);
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pause-control-form button:hover,
button.tertiary:hover {
    background-color: var(--action-tertiary-hover-bg);
    border-color: #adb5bd;
}

button.secondary {
    background-color: var(--action-secondary-bg);
    color: var(--light-text-on-accent);
    border: 1px solid var(--action-secondary-bg);
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 16px;
}

button.secondary:hover {
    background-color: var(--action-secondary-hover-bg);
    border-color: var(--action-secondary-hover-bg);
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--action-primary-bg);
    color: var(--light-text-on-accent);
    border: 1px solid var(--action-primary-bg);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.02s ease;
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.25);
}

.primary-button:hover {
    background-color: var(--action-primary-hover-bg);
}

.primary-button:active {
    transform: translateY(1px);
}

/* Generic text inputs used across dashboard (Meta templates, filters, etc.) */
.input-text {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--light-border-input);
    background-color: var(--light-input-bg);
    color: var(--light-text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.input-text.small {
    padding: 6px 9px;
    font-size: 12px;
}

.input-text::placeholder {
    color: var(--light-text-secondary);
    opacity: 0.8;
}

.input-text:focus {
    outline: none;
    border-color: var(--action-primary-bg);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.10);
}

.input-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--light-border-input);
    background-color: var(--light-input-bg);
    color: var(--light-text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.input-textarea.small {
    font-size: 12px;
}

.input-textarea::placeholder {
    color: var(--light-text-secondary);
    opacity: 0.8;
}

.input-textarea:focus {
    outline: none;
    border-color: var(--action-primary-bg);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.10);
}

/* Compact primary button for Meta templates actions */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--action-primary-bg);
    background-color: var(--action-primary-bg);
    color: var(--light-text-on-accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
    transition: background-color 0.18s ease, box-shadow 0.18s ease, transform 0.06s ease;
}

.primary-btn:hover {
    background-color: var(--action-primary-hover-bg);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
}

.primary-btn:active {
    transform: translateY(1px);
}

/* Enrollment toggle button */
button.enrollment-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 16px;
    background-color: var(--light-bg-primary);
    border: 1px solid var(--light-border-input);
}

button.enrollment-toggle-btn svg {
    color: var(--link-color);
}

button.enrollment-toggle-btn:hover {
    background-color: rgba(0, 122, 255, 0.06);
    border-color: var(--link-color);
}

#enrollmentToggleContainer { margin-left: 10px; }

/* Status indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 7px;
}

.status-indicator-active {
    background-color: #1aa37a;
}

.status-indicator-paused {
    background-color: #fd7e14;
}

/* Status Pills */
.status-pill-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.delete-status-btn {
    display: none;
    position: absolute;
    top: -5px;
    right: -1px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #555;
    color: white;
    border: 1px solid white;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    z-index: 1;
    font-weight: bold;
    padding: 0;
}

.status-pill-wrapper:hover .delete-status-btn {
    display: block;
}

.delete-status-btn:hover {
    background-color: #dc3545;
}

/* Spinner */
.spinner-container {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top-color: #4A90E2;
    animation: spin 1s ease-in-out infinite;
}

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

/* Flash Messages */
.flashes-container-fixed {
    position: fixed;
    top: calc(50px + 15px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: auto;
    max-width: 450px;
}

ul.flashes {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

li.flash-message {
    padding: 12px 20px;
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    opacity: 0;
    animation: flashMessageLifecycle 5s ease-in-out forwards;
    border: 1px solid transparent;
}

@keyframes flashMessageLifecycle {
    0% { opacity: 0; transform: translateY(-10px); }
    10% { opacity: 0.95; transform: translateY(0); }
    90% { opacity: 0.95; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

li.flash-message.success {
    background-color: var(--flash-success-bg);
    color: var(--flash-success-text);
    border-color: #b1dfbb;
}

li.flash-message.error {
    background-color: var(--flash-error-bg);
    color: var(--flash-error-text);
    border-color: #f1b0b7;
}

li.flash-message.warning {
    background-color: var(--flash-warning-bg);
    color: var(--flash-warning-text);
    border-color: #ffe58f;
}

li.flash-message.info {
    background-color: var(--flash-info-bg);
    color: var(--flash-info-text);
    border-color: #a6dcef;
}

/* === Meta Templates (WhatsApp) === */

.meta-templates-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 20px;
    margin-top: 18px;
}

.meta-templates-list-panel,
.meta-templates-detail-panel {
    background: var(--light-bg-secondary);
    border-radius: 14px;
    border: 1px solid var(--light-border-primary);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
    padding: 14px 14px 16px 14px;
    display: flex;
    flex-direction: column;
    min-height: 260px;
}

.meta-templates-list-panel {
    align-self: flex-start;
}

.meta-templates-list-panel .panel-header,
.meta-templates-detail-panel .meta-template-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.meta-templates-list-panel h4,
.meta-template-header h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--light-text-primary);
}

.meta-templates-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.meta-templates-filters .input-text.small {
    flex: 1;
}

.meta-templates-list {
    flex: 1;
    border-radius: 10px;
    background: var(--light-bg-primary);
    border: 1px solid var(--light-border-primary);
    padding: 4px;
    overflow-y: auto;
    max-height: 380px;
}

.meta-templates-list .empty-state {
    padding: 16px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--light-text-secondary);
}

.file-upload-wrapper .clear-file-btn {
    display: none; 
    background: none; 
    border: none; 
    cursor: pointer; 
    color: var(--text-secondary); 
    padding: 2px; 
    margin-left: -4px;
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.file-upload-wrapper:hover .clear-file-btn.has-file {
    display: inline-flex !important;
}

.file-upload-wrapper .clear-file-btn:hover {
    opacity: 1;
    color: var(--flash-error-text);
}

.meta-template-item {
    width: 100%;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 8px 10px;
    text-align: left;
    background: transparent;
    color: var(--light-text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.03s ease;
}

.meta-template-item:hover {
    background-color: rgba(15, 23, 42, 0.03);
    border-color: var(--light-border-primary);
}

.meta-template-item.active {
    background-color: rgba(0, 122, 255, 0.10);
    border-color: var(--action-primary-bg);
}

.meta-templates-detail-panel.is-hidden {
    display: none;
}

.meta-template-item .item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.meta-template-item .item-name {
    font-size: 14px;
    font-weight: 600;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-template-item .item-meta {
    font-size: 11px;
    color: var(--light-text-secondary);
}

.meta-template-item .item-body-preview {
    font-size: 11px;
    color: var(--light-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-template-detail {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.meta-template-meta {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--light-text-secondary);
}

.meta-template-body-preview h5,
.meta-template-variables-config h5,
.meta-template-send-modes h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--light-text-primary);
}

.meta-template-body-preview pre.code-block {
    background: var(--light-bg-tertiary);
    color: var(--light-text-primary);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-family: var(--font-primary);
    line-height: 1.5;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.template-buttons-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.template-button-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--light-bg-secondary);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    font-size: 13px;
    color: #0891b2;
    font-weight: 500;
}

.template-button-preview svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    flex-shrink: 0;
}

.variables-list-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.02);
    border: 1px dashed rgba(148, 163, 184, 0.5);
}

.variable-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.variable-label {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    color: var(--light-text-secondary);
}

.meta-template-send-modes .tabs-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.meta-template-send-modes .tab-chip {
    border-radius: 999px;
    border: 1px solid var(--light-border-primary);
    background: var(--light-bg-primary);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--light-text-secondary);
}

.meta-template-send-modes .tab-chip.active {
    background: rgba(0, 122, 255, 0.10);
    border-color: var(--action-primary-bg);
    color: var(--action-primary-bg);
}

.meta-template-send-modes .tabs-content {
    border-radius: 10px;
    border: 1px solid var(--light-border-primary);
    background: var(--light-bg-primary);
    padding: 10px 12px 12px 12px;
}

.meta-template-send-modes .tab-panel {
    display: none;
}

.meta-template-send-modes .tab-panel.active {
    display: block;
}

.meta-template-send-modes .actions-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.results-container.small {
    margin-top: 8px;
}

.results-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--light-text-secondary);
}

.badge.ok,
.badge.error {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 999px;
    font-weight: 600;
}

.badge.ok {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.badge.error {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.badge.pending {
    background: rgba(251, 191, 36, 0.15);
    color: #d97706;
    animation: pulse-pending 1.5s ease-in-out infinite;
}

@keyframes pulse-pending {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-pill.small {
    font-size: 11px;
    padding: 4px 8px;
}

.status-pill.tiny {
    font-size: 10px;
    padding: 2px 6px;
}

.status-pill.status-ok {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.status-pill.status-warn {
    background: rgba(234, 179, 8, 0.12);
    color: #ca8a04;
}

.status-pill.status-error {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.status-error {
    color: #dc2626 !important;
}


