/* ============================================
   SMS Panel V2 — Modern UI Design System
   Premium glassmorphism + gradients + animations
   ============================================ */

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

:root {
    --ui-primary: #4F46E5;
    --ui-primary-light: #818CF8;
    --ui-primary-dark: #3730A3;
    --ui-emerald: #10B981;
    --ui-emerald-light: #34D399;
    --ui-amber: #F59E0B;
    --ui-amber-light: #FCD34D;
    --ui-rose: #F43F5E;
    --ui-rose-light: #FB7185;
    --ui-cyan: #06B6D4;
    --ui-violet: #8B5CF6;
    --ui-slate-50: #F8FAFC;
    --ui-slate-100: #F1F5F9;
    --ui-slate-200: #E2E8F0;
    --ui-slate-700: #334155;
    --ui-slate-800: #1E293B;
    --ui-slate-900: #0F172A;
    --ui-glass-bg: rgba(255, 255, 255, 0.7);
    --ui-glass-border: rgba(255, 255, 255, 0.3);
    --ui-glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.12);
    --ui-radius: 16px;
    --ui-radius-sm: 10px;
    --ui-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Base Typography ─── */
body,
.app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6,
.card-title,
.page-title {
    font-family: 'Inter', sans-serif !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}

/* ─── Glass Cards ─── */
.card {
    background: var(--ui-glass-bg) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--ui-glass-border) !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-glass-shadow) !important;
    transition: var(--ui-transition);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(31, 38, 135, 0.18) !important;
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    font-weight: 600 !important;
    padding: 1.25rem 1.5rem !important;
}

/* ─── Gradient Stat Cards ─── */
.stat-card {
    border-radius: var(--ui-radius) !important;
    border: none !important;
    color: #fff;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    transition: var(--ui-transition);
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.01);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.85;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-gradient-1 {
    background: linear-gradient(135deg, #4F46E5, #7C3AED) !important;
}

.stat-gradient-2 {
    background: linear-gradient(135deg, #10B981, #059669) !important;
}

.stat-gradient-3 {
    background: linear-gradient(135deg, #F59E0B, #D97706) !important;
}

.stat-gradient-4 {
    background: linear-gradient(135deg, #F43F5E, #E11D48) !important;
}

.stat-gradient-5 {
    background: linear-gradient(135deg, #06B6D4, #0891B2) !important;
}

.stat-gradient-6 {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED) !important;
}

.stat-gradient-7 {
    background: linear-gradient(135deg, #EC4899, #DB2777) !important;
}

.stat-gradient-8 {
    background: linear-gradient(135deg, #14B8A6, #0D9488) !important;
}

/* ─── Animated Number Counter ─── */
.count-up {
    display: inline-block;
}

/* ─── Modern Buttons ─── */
.btn-modern-primary {
    background: linear-gradient(135deg, var(--ui-primary), var(--ui-violet));
    border: none;
    color: #fff;
    padding: 0.625rem 1.5rem;
    border-radius: var(--ui-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--ui-transition);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-modern-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
    color: #fff;
}

.btn-modern-success {
    background: linear-gradient(135deg, var(--ui-emerald), #059669);
    border: none;
    color: #fff;
    padding: 0.625rem 1.5rem;
    border-radius: var(--ui-radius-sm);
    font-weight: 600;
    transition: var(--ui-transition);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-modern-success:hover {
    transform: translateY(-1px);
    color: #fff;
}

.btn-ai-generate {
    background: linear-gradient(135deg, #7C3AED, #EC4899);
    border: none;
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: var(--ui-radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--ui-transition);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-ai-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
    color: #fff;
}

.btn-ai-generate i {
    margin-right: 6px;
}

/* ─── Quick Action Cards ─── */
.quick-action-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--ui-radius) !important;
    cursor: pointer;
    transition: var(--ui-transition);
    border: 2px solid transparent !important;
}

.quick-action-card:hover {
    border-color: var(--ui-primary) !important;
    transform: translateY(-3px);
}

.quick-action-card .action-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.5rem;
    color: #fff;
}

/* ─── Live Activity Feed ─── */
.activity-feed {
    max-height: 350px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: var(--ui-transition);
}

.activity-item:hover {
    background: rgba(79, 70, 229, 0.03);
    border-radius: 8px;
    padding-left: 8px;
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.sent {
    background: var(--ui-emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.activity-dot.failed {
    background: var(--ui-rose);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
}

/* ─── System Health Widget ─── */
.health-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.health-good {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ui-emerald);
}

.health-warn {
    background: rgba(245, 158, 11, 0.1);
    color: var(--ui-amber);
}

.health-bad {
    background: rgba(244, 63, 94, 0.1);
    color: var(--ui-rose);
}

/* ─── AI Panel ─── */
.ai-panel {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(236, 72, 153, 0.05));
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--ui-radius);
    padding: 1.5rem;
}

.ai-panel .ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 1rem;
    color: #7C3AED;
}

.ai-badge {
    background: linear-gradient(135deg, #7C3AED, #EC4899);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.ai-preview-box {
    background: rgba(255, 255, 255, 0.8);
    border: 1px dashed rgba(124, 58, 237, 0.3);
    border-radius: var(--ui-radius-sm);
    padding: 1rem;
    min-height: 100px;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ─── Enhanced Form Controls ─── */
.form-control:focus,
.form-select:focus {
    border-color: var(--ui-primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ui-slate-700);
}

/* ─── Toast Notifications ─── */
.toast-modern {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    padding: 1rem 1.5rem;
    border-radius: var(--ui-radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.4s ease;
    max-width: 400px;
}

.toast-success {
    background: linear-gradient(135deg, #10B981, #059669);
}

.toast-error {
    background: linear-gradient(135deg, #F43F5E, #E11D48);
}

.toast-info {
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
}

/* ─── Fade-in Animation ─── */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

.fade-in-up:nth-child(1) {
    animation-delay: 0.05s;
}

.fade-in-up:nth-child(2) {
    animation-delay: 0.1s;
}

.fade-in-up:nth-child(3) {
    animation-delay: 0.15s;
}

.fade-in-up:nth-child(4) {
    animation-delay: 0.2s;
}

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(79, 70, 229, 0.3);
    }

    50% {
        box-shadow: 0 0 15px rgba(79, 70, 229, 0.6);
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(79, 70, 229, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 70, 229, 0.5);
}

/* ─── Monitor Filters Bar ─── */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 1rem 0;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
}

.filter-bar .form-control,
.filter-bar .form-select {
    border-radius: var(--ui-radius-sm);
    font-size: 0.85rem;
}

.stats-summary-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.stats-summary-item {
    background: var(--ui-glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--ui-radius-sm);
    padding: 0.75rem 1.25rem;
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.stats-summary-item .ss-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.stats-summary-item .ss-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

/* ─── Template Ownership Badge ─── */
.badge-global {
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    color: #fff;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 12px;
}

.badge-user {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 12px;
}

/* ─── Page Header ─── */
.page-header {
    margin-bottom: 1.5rem !important;
}

.page-title {
    font-size: 1.5rem !important;
    background: linear-gradient(135deg, var(--ui-primary), var(--ui-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Table Modern ─── */
.table {
    border-radius: var(--ui-radius-sm);
    overflow: hidden;
}

.table thead th {
    background: var(--ui-slate-50);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-slate-700);
    border: none !important;
    padding: 0.875rem 1rem;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.75rem 1rem;
}

.table tbody tr {
    transition: var(--ui-transition);
}

.table tbody tr:hover {
    background: rgba(79, 70, 229, 0.03);
}

/* ─── Dark Mode Overrides ─── */
.dark-mode .card {
    background: rgba(30, 41, 59, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.dark-mode .card-header {
    border-color: rgba(255, 255, 255, 0.06) !important;
}

.dark-mode .table thead th {
    background: rgba(15, 23, 42, 0.5);
    color: #94A3B8;
}

.dark-mode .form-label {
    color: #CBD5E1;
}

.dark-mode .ai-panel {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(236, 72, 153, 0.08));
    border-color: rgba(124, 58, 237, 0.2);
}

.dark-mode .ai-preview-box {
    background: rgba(15, 23, 42, 0.6);
}

.dark-mode .stats-summary-item {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

.dark-mode .quick-action-card:hover {
    border-color: var(--ui-primary-light) !important;
}

/* ─── Loading Spinner ─── */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.spinner-modern {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--ui-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .stat-card .stat-icon {
        font-size: 1.75rem;
    }

    .filter-bar {
        flex-direction: column;
    }

    .stats-summary-bar {
        flex-direction: column;
    }
}