/* ===== COMPONENTS ===== */

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.toggle-wrapper.start-hidden {
    opacity: 0;
    pointer-events: none;
}

.toggle-wrapper.visible {
    opacity: 1;
    pointer-events: auto;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--map-stroke);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--border-light);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
    border-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.label {
    font-size: var(--text-sm);
    font-weight: 500;
}

/* Tool Button */
.tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    color: var(--text-highlight);
    font-size: var(--text-xl);
    cursor: pointer;
    backdrop-filter: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Placeholder Card */
.placeholder-card {
    background: transparent;
    /* No card background */
    border: none;
    border-radius: 0;
    padding: 2rem 1rem;
    text-align: center;
    max-width: 600px;
    margin: 2rem auto;
    backdrop-filter: none;
}

.icon-placeholder {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(6, 182, 212, 0.2));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.placeholder-card h2 {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.placeholder-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* Page Loader */
.page-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-deep);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner-box {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.loader-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    animation: float 2s infinite ease-in-out;
}

.pulse-ring {
    position: absolute;
    inset: -10px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: pulse-ring 2s infinite;
}

@keyframes float {

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

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

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

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.error-state h2 {
    font-size: var(--text-2xl);
    margin-bottom: 0.5rem;
    color: #ef4444;
}

.error-state p {
    color: var(--text-muted);

}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-secondary) 25%,
            #475569 50%,
            var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 120px;
    width: 100%;
    margin-bottom: var(--space-4);
}

.skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: var(--space-2);
}

.skeleton-text-short {
    width: 60%;
}

/* Active Filter Chips */
.active-filter-bar {
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slide-down 0.2s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

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

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
}

.filter-chip-label {
    color: var(--text-muted);
    margin-right: 4px;
}

.filter-chip-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    transition: all 0.2s;
}

.filter-chip-remove:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ef4444;
}

.clear-all-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
    white-space: nowrap;
}

.clear-all-btn:hover {
    color: var(--text-main);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
    pointer-events: none;
    /* Allow clicking through container */
}

.toast {
    background: var(--surface-card);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    animation: toast-slide-in var(--duration-normal) var(--ease-out);
    pointer-events: auto;
    /* Re-enable clicks on toast */
    color: var(--text-primary);
    min-width: 300px;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.toast-success {
    border-left-color: var(--color-success, #10B981);
}

.toast.toast-error {
    border-left-color: var(--color-danger, #EF4444);
}

.toast.toast-warning {
    border-left-color: var(--color-warning, #F59E0B);
}

.toast.toast-info {
    border-left-color: var(--color-info, #3B82F6);
}

.toast-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-content {
    flex: 1;
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-main);
    line-height: 1.4;
}

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

.toast-close:hover {
    color: var(--text-primary);
}

/* Bulk Actions Bar */
.bulk-actions-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 24px;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(12px);
    min-width: 400px;
}

.bulk-actions-bar.visible {
    transform: translateX(-50%) translateY(0);
}

.bulk-selection-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
    border-right: 1px solid var(--border-light);
    padding-right: 24px;
}

#bulk-selected-count {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-color);
}

.bulk-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.bulk-actions-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.bulk-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.bulk-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.bulk-btn.btn-danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.bulk-btn.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.bulk-divider {
    width: 1px;
    height: 24px;
    background: var(--border-light);
    margin: 0 4px;
}

.bulk-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin-left: auto;
}

.bulk-close-btn:hover {
    color: var(--text-main);
}

/* Table Checkbox */
.table-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-color);
    border-radius: 4px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    /* controlled by JS (flex or none) */
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
    animation: scaleUp 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}

.filter-select:focus {
    border-color: var(--accent-color);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 768px) {

    /* Dealer Table Container - Scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Filters allow wrapping */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        gap: var(--space-3);
    }

    .filter-group {
        flex-wrap: wrap;
        width: 100%;
    }

    .filter-select {
        flex: 1;
        min-width: 120px;
    }

    /* Adjust page title bar for mobile */
    .page-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
        height: auto;
        padding: var(--space-4);
    }

    .page-title-content {
        width: 100%;
    }

    .page-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }
}

@keyframes scaleUp {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modern Action Buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

.action-btn svg {
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.08);
}

.action-btn:active {
    transform: translateY(0);
}

/* View Button - Blue Theme */
.action-btn.view-btn {
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.action-btn.view-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
    color: #93c5fd;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
}

.action-btn.view-btn:hover svg {
    transform: scale(1.1);
}

/* Duplicate Button - Purple Theme */
.action-btn.duplicate-btn {
    border-color: rgba(168, 85, 247, 0.3);
    color: #c084fc;
}

.action-btn.duplicate-btn:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.5);
    color: #e9d5ff;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.25);
}

.action-btn.duplicate-btn:hover svg {
    transform: scale(1.1) rotate(5deg);
}

/* Delete Button - Red Theme */
.action-btn.campaign-delete-btn {
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.action-btn.campaign-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

.action-btn.campaign-delete-btn:hover svg {
    transform: scale(1.1);
}

/* Modernized WhatsApp Section */
.whatsapp-modern-card {
    background: rgba(16, 185, 129, 0.03);
    border: 1px solid rgba(16, 185, 129, 0.1);
    border-radius: 20px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.whatsapp-header-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.whatsapp-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #10b981;
}

.whatsapp-title-wrapper h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wa-status-pill {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.wa-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: relative;
    background: #475569;
}

.wa-status-pill.connected {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #f8fafc;
}

.wa-status-pill.connected .wa-status-dot {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.wa-status-pill.connected .wa-status-dot::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 1px solid #10b981;
    border-radius: 50%;
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.wa-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.wa-action-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.wa-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    transform: translateY(-1px);
}

.wa-action-btn svg {
    width: 18px;
    height: 18px;
}

.wa-modern-select-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.wa-modern-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: #f8fafc;
    font-size: 0.85rem;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s;
}

.wa-modern-select:focus {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.wa-modern-select option {
    background: #0f172a;
    color: #f8fafc;
}

.wa-modern-select-wrapper::after {
    content: '▾';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
    font-size: 0.7rem;
}

.wa-message-composer {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 4px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.wa-message-composer:focus-within {
    border-color: rgba(16, 185, 129, 0.3);
}

.wa-message-composer textarea {
    width: 100%;
    min-height: 80px;
    background: transparent;
    border: none;
    color: #f1f5f9;
    padding: 12px;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.wa-send-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.wa-send-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.wa-send-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: #475569;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.5;
}

.wa-preview-container {
    margin-bottom: 15px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(16, 185, 129, 0.1);
}