/* Meta Ads App Styles - Enhanced UI */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-blue: #1877f2;
    --facebook-blue: #1877f2;
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --error-red: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

html {
    overflow-x: auto;
    max-width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: var(--gray-900);
    overflow-x: auto;
    max-width: 100%;
}

/* Authentication Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.auth-card {
    padding: 3rem;
    min-height: 400px;
    min-width: 400px;
    position: relative;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    height: 60px;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--gray-600);
}

.auth-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-facebook {
    background: #1877f2;
    color: var(--white);
}

.btn-facebook:hover {
    background: #166fe5;
}

/* Empty State Features */
.empty-state-features {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.feature-item:hover {
    background: var(--gray-100);
    transform: translateY(-1px);
}

.feature-item i {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.feature-item span {
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.4;
}

.btn-block {
    width: 100%;
}

.auth-divider {
    text-align: center;
    color: var(--gray-400);
    margin: 1.5rem 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gray-200);
    z-index: 1;
}

.auth-divider {
    background: var(--white);
    padding: 0 1rem;
    position: relative;
    z-index: 2;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.auth-footer a {
    color: var(--primary-blue);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-features {
    background: var(--gray-50);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-features h3 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--gray-900);
}

.auth-features ul {
    list-style: none;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    color: var(--gray-700);
    font-weight: 500;
}

.auth-features i {
    color: var(--primary-blue);
    font-size: 1.25rem;
}

/* Dashboard Styles */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--gray-50);
}

.sidebar {
    width: 280px;
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.sidebar-logo {
    height: 100px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-text {
    flex: 1;
    padding-top: 0.5rem;
    text-align: center;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    text-align: center;
}

.nav-menu {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 2rem;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.nav-item.active {
    background: var(--primary-blue);
    color: var(--white);
}

.nav-item i {
    font-size: 1.125rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

/* Locked navigation items for users without page access */
.nav-item.nav-locked {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-item.nav-locked i {
    color: var(--gray-400);
}

.nav-item.nav-locked span {
    color: var(--gray-400);
}

.nav-item.nav-locked:hover {
    background: transparent;
    color: var(--gray-400);
}

.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 2rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.page-subtitle {
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--gray-200);
    min-width: 250px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.user-dropdown-email {
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 500;
    word-break: break-all;
}

.user-dropdown-role {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.user-dropdown-item:hover {
    background: var(--gray-100);
}

.user-dropdown-item i {
    width: 16px;
    color: var(--gray-500);
}

.user-dropdown-item.sign-out {
    color: #dc2626;
    border-top: 1px solid var(--gray-200);
}

.user-dropdown-item.sign-out i {
    color: #dc2626;
}

/* Cards and Components */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-content {
    padding: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.stat-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stat-icon {
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 1.125rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success-green);
}

.stat-change.negative {
    color: var(--error-red);
}

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

.data-table th {
    background: var(--gray-50);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.data-table tr:hover {
    background: var(--gray-50);
}

/* Buttons */
.btn-success {
    background: var(--success-green);
    color: var(--white);
}

.btn-success:hover {
    background: #369870;
}

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

.btn-warning:hover {
    background: #e6850e;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: #fafaff;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior: contain; /* Prevent scroll chaining to body */
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .auth-container {
        grid-template-columns: 1fr;
    }

    .auth-features {
        display: none;
    }

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

/* Loading States */
.loading {
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced UI Components */
.stat-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease-out;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

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

/* Skeleton Loading for Charts */
.chart-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
    height: 300px;
}

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

/* Improved Chart Container */
.performance-chart {
    position: relative;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.performance-chart canvas {
    transition: opacity 0.3s ease;
}

/* Loading overlay for charts */
.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}

/* Better button styles */
.btn {
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24, 119, 242, 0.15);
}

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

/* Improved campaign cards */
.campaign-card {
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.campaign-card:hover {
    border-left-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Better tab transitions */
.tab-content {
    animation: fadeIn 0.3s ease-out;
}

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

/* Improved modal backdrop */
.modal {
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.5);
}

/* Success/Error message animations */
.message {
    animation: slideInRight 0.3s ease-out;
}

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

/* Redesigned Top Section */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 0;
}

.nav-left .breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.breadcrumb-item {
    color: var(--gray-500);
    transition: color 0.2s ease;
}

.breadcrumb-item:hover {
    color: var(--primary-blue);
    cursor: pointer;
}

.breadcrumb-item.active {
    color: var(--gray-900);
    font-weight: 500;
}

.breadcrumb i {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-ghost:hover {
    background: var(--gray-50);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
    transform: none;
    box-shadow: none;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: 20px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
}

.status-dot.connected {
    background: var(--success-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.status-text {
    color: var(--gray-700);
    font-weight: 500;
}

/* Redesigned Page Header */
.page-header-redesigned {
    padding: 2rem 2rem 1rem 2rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #3b82f6 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.page-header-redesigned::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.1) 100%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.header-main .page-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.header-main .page-subtitle {
    font-size: 1.125rem;
    opacity: 0.95;
    margin: 0;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 400;
}

.header-stats {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
}

.quick-stat {
    text-align: center;
    min-width: 100px;
}

.quick-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.quick-stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
    color: rgba(255, 255, 255, 0.9);
}

/* CPA Color Logic - Green when down, Red when up */
.stat-change {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.stat-change.positive {
    color: var(--success-green);
}

.stat-change.negative {
    color: var(--error-red);
}

/* CPA specific colors (opposite logic) */
.stat-change.cpa-decrease {
    color: var(--success-green) !important;
}

.stat-change.cpa-increase {
    color: var(--error-red) !important;
}

/* Adjust main content spacing */
.dashboard-content {
    margin-top: 0;
}

.stats-grid {
    margin-top: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .top-nav {
        padding: 0.75rem 1rem;
    }

    .page-header-redesigned {
        padding: 1.5rem 1rem 1rem 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .header-main .page-title {
        font-size: 2rem;
    }

    .header-stats {
        align-self: stretch;
        justify-content: space-between;
    }

    .nav-right {
        gap: 1rem;
    }
}

/* AI Recommendations Accordion Design */
.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Accordion Styles */
.recommendation-accordion {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: all 0.3s ease;
}

.recommendation-accordion:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Accordion Header */
.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.accordion-header:hover {
    background: var(--gray-50);
}

.accordion-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.accordion-content {
    flex: 1;
}

.accordion-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.accordion-meta {
    font-size: 0.875rem;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.ad-name {
    font-weight: 500;
    color: var(--primary-blue);
}

.accordion-meta .campaign-name,
.accordion-meta .adset-name {
    color: var(--gray-500);
    font-size: 0.8rem;
    font-weight: 400;
}

.spend-info {
    color: var(--gray-500);
    font-weight: 500;
}

.accordion-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.rec-icon-small {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.rec-icon-small.high {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.rec-icon-small.medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.rec-icon-small.low {
    background: linear-gradient(135deg, #10b981, #059669);
}

.priority-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.priority-badge.high {
    background: #fef2f2;
    color: #dc2626;
}

.priority-badge.medium {
    background: #fffbeb;
    color: #d97706;
}

.priority-badge.low {
    background: #f0fdf4;
    color: #059669;
}

.spend-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    font-weight: 600;
    color: #0369a1;
    font-size: 0.875rem;
    line-height: 1.2;
    min-width: 60px;
    text-align: center;
}

.spend-badge span {
    font-size: 0.65rem;
    font-weight: 500;
    color: #0284c7;
    margin-top: 0.125rem;
}

.accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--gray-400);
}

.accordion-toggle i {
    transition: transform 0.3s ease;
}

/* Accordion Body */
.accordion-body {
    display: none;
    padding: 1.25rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.detail-row {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.ad-preview {
    flex-shrink: 0;
}

.recommendation-details {
    flex: 1;
}

.rec-description p {
    color: var(--gray-700);
    line-height: 1.6;
    margin: 0 0 1rem 0;
}

.metrics-compact {
    margin: 1rem 0;
}

.metric-pair {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.metric-current {
    color: #d97706;
    font-weight: 500;
}

.metric-target {
    color: #059669;
    font-weight: 500;
}

.metric-pair i {
    color: var(--gray-400);
    font-size: 0.875rem;
}

.impact-compact {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: #0369a1;
    font-size: 0.875rem;
    margin: 1rem 0;
}

/* Agent Trigger Info */
.agent-trigger-info {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
}

.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.agent-badge i {
    font-size: 1rem;
}

.agent-badge.agent-buyer {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.agent-badge.agent-creative {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.agent-badge.agent-analyst {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* ============================================
   Enhanced Recommendation Card Styles
   Visual storytelling components
   ============================================ */

/* Metric Cards Grid */
.metric-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.75rem;
}

.metric-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.875rem;
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

/* Status Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-pill i {
    font-size: 0.6rem;
}

/* Diagnosis Timeline */
.diagnosis-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.diagnosis-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0 8px 8px 0;
    transition: all 0.2s ease;
}

.diagnosis-item:hover {
    transform: translateX(2px);
}

.diagnosis-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    color: white;
}

/* Impact Callout */
.impact-callout {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    position: relative;
    overflow: hidden;
}

.impact-callout:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.section-header span {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Next Steps */
.steps-list {
    background: #eff6ff;
    border-radius: 10px;
    padding: 0.75rem 1rem;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.step-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Combined Insights */
.combined-insights .insight-item {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.combined-insights .insight-item:hover {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

/* General Insight Cards */
.general-insight {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.general-insight:hover {
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

/* Savings Badge */
.savings-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: white;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #047857;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Recommendation Body Content */
.recommendation-body-content {
    padding: 0.5rem 0;
}

/* Animation for accordion expand */
.accordion-body.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.accordion-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.accordion-actions .btn {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.rec-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.rec-icon.high {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.rec-icon.medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.rec-icon.low {
    background: linear-gradient(135deg, #10b981, #059669);
}

.rec-title-section {
    flex: 1;
}

.rec-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

.rec-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ai-badge, .ad-age-badge, .general-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.ai-badge {
    background: var(--primary-blue);
    color: white;
}

.ad-age-badge {
    background: var(--gray-100);
    color: var(--gray-700);
}

.ad-age-badge.new {
    background: #dcfce7;
    color: #166534;
}

.ad-age-badge.testing {
    background: #fef3c7;
    color: #92400e;
}

.ad-age-badge.scaling {
    background: #dbeafe;
    color: #1e40af;
}

.ad-age-badge.mature {
    background: var(--gray-100);
    color: var(--gray-600);
}

.general-badge {
    background: #f3e8ff;
    color: #7c2d92;
}

.priority-indicator {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    min-width: 80px;
}

.priority-indicator.high {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.priority-indicator.medium {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fed7aa;
}

.priority-indicator.low {
    background: #f0fdf4;
    color: #059669;
    border: 1px solid #bbf7d0;
}

/* Asset Preview */
.asset-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.asset-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    font-weight: 500;
}

.asset-thumbnail.creative {
    background: linear-gradient(135deg, #ec4899, #be185d);
}

.asset-thumbnail.copy {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.asset-thumbnail.optimization {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.asset-thumbnail span {
    font-size: 0.6rem;
    margin-top: 2px;
}

.asset-info {
    flex: 1;
}

.asset-type {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.asset-format {
    color: var(--gray-600);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Compact Asset Thumbnails for Accordion Headers */
.asset-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: white;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.asset-thumb.creative {
    background: linear-gradient(135deg, #ec4899, #be185d);
}

.asset-thumb.copy {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.asset-thumb.budget {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.asset-thumb.targeting {
    background: linear-gradient(135deg, #10b981, #059669);
}

.asset-thumb.optimization {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.compact-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    font-size: 0.625rem;
    color: white;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.compact-thumb.ad-thumb {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.compact-thumb.creative {
    background: linear-gradient(135deg, #ec4899, #be185d);
}

.compact-thumb.copy {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.compact-thumb.budget {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.compact-thumb.targeting {
    background: linear-gradient(135deg, #10b981, #059669);
}

.compact-thumb.optimization {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

/* Ad Preview Cards for Accordion */
.ad-preview-card-small {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    width: 120px;
}

.ad-preview-thumbnail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-radius: 6px;
    font-size: 1.5rem;
    gap: 0.5rem;
}

.ad-preview-thumbnail span {
    font-size: 0.75rem;
    font-weight: 500;
}

.ad-preview-info {
    text-align: center;
}

.ad-id-label {
    font-size: 0.7rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.preview-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    background: var(--primary-blue);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.preview-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* General Preview Cards */
.general-preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 100px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    gap: 0.5rem;
}

.general-preview-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.general-preview-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
    text-align: center;
}

/* Ad Preview Components */
.ad-preview-container {
    height: 800px;
    margin: 0 auto;
    flex-shrink: 0;
}

.ad-preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    color: var(--gray-600);
    font-size: 0.875rem;
    min-height: 200px;
}

.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ad-preview-frame {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    background: var(--white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    width: 335px;
    height: 800px;
}

.ad-preview-frame iframe {
    width: 335px !important;
    height: 800px !important;
    border: none !important;
    border-radius: 8px !important;
    display: block !important;
    overflow: hidden !important;
    background: var(--white) !important;

    /* Prevent scrollbars */
    scrolling: no !important;
    -webkit-overflow-scrolling: touch !important;

    /* Auto-resize to content */
    resize: none !important;
}

/* Ensure iframe content fits properly */
.ad-preview-frame iframe body {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Style the iframe wrapper for better presentation */
.ad-preview-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 8px 8px 0 0;
    z-index: 1;
}

.ad-preview-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    color: var(--gray-500);
    font-size: 0.875rem;
    text-align: center;
    min-height: 200px;
}

.ad-preview-error i {
    font-size: 1.5rem;
    opacity: 0.5;
}

/* Responsive adjustments for ad previews */
@media (max-width: 768px) {
    .ad-preview-container {
        height: 800px;
    }

    .ad-preview-frame {
        width: 335px;
        height: 800px;
    }

    .ad-preview-frame iframe {
        width: 335px !important;
        height: 800px !important;
    }
}

/* Performance Chart Loading Styles */
.performance-chart-container {
    position: relative;
    min-height: 300px;
    text-align: center;
}

.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

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

.chart-loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-spinner-chart {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* Ensure spinner animation is defined */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Analyst Agent Loading Spinner */
.analyst-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.analyst-loading-state {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 12px;
    border: 1px dashed rgba(102, 126, 234, 0.3);
}

.loading-spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Clean Campaign Item Styles */
.campaign-item-clean {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.campaign-item-clean:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.campaign-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: var(--white);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.campaign-content {
    flex: 1;
    min-width: 0;
}

.campaign-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.campaign-name {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.performance-badge {
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.performance-badge.high-performance {
    background: #dcfce7;
    color: #166534;
}

.performance-badge.good-performance {
    background: #dbeafe;
    color: #1d4ed8;
}

.performance-badge.moderate-performance {
    background: #fef3c7;
    color: #92400e;
}

.performance-badge.low-performance {
    background: #fee2e2;
    color: #dc2626;
}

.campaign-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.metric-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* Clean Ad Item Styles */
.ad-item-clean {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.ad-item-clean:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--gray-300);
}

.ad-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: var(--white);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.ad-content {
    flex: 1;
    min-width: 0;
}

.ad-header-clean {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
}

.ad-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.performance-indicator {
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.675rem;
    font-weight: 600;
    flex-shrink: 0;
}

.performance-indicator.excellent {
    background: #dcfce7;
    color: #166534;
}

.performance-indicator.good {
    background: #dbeafe;
    color: #1d4ed8;
}

.performance-indicator.average {
    background: #fef3c7;
    color: #92400e;
}

.performance-indicator.below-average {
    background: #fee2e2;
    color: #dc2626;
}

.ad-campaign-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--gray-600);
    min-height: 2.4rem; /* Reserve space for 2 lines */
    line-height: 1.2;
}

.campaign-label {
    font-weight: 500;
}

.separator {
    opacity: 0.5;
}

.adset-label {
    opacity: 0.8;
}

.ad-metrics-compact {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.metric-compact {
    text-align: center;
    padding: 0.5rem;
    background: var(--gray-50);
    border-radius: 6px;
}

.metric-compact .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.metric-compact .label {
    font-size: 0.7rem;
    color: var(--gray-600);
    margin-top: 0.125rem;
    line-height: 1.2;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .campaign-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .ad-metrics-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .campaign-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .ad-header-clean {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Card Body */
.card-body {
    padding: 1.5rem;
}

.rec-description p {
    color: var(--gray-700);
    line-height: 1.6;
    margin: 0 0 1.5rem 0;
}

.rec-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-900);
}

.spend-value {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.spend-note {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--gray-500);
}

/* Metrics Grid */
.rec-metrics-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.metric-card {
    text-align: center;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    background: white;
}

.metric-card.current {
    border-color: #fbbf24;
    background: #fffbeb;
}

.metric-card.target {
    border-color: #34d399;
    background: #f0fdf4;
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.metric-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 1rem;
}

/* Impact Section */
.impact-section {
    padding: 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.impact-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #0369a1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.impact-value {
    font-size: 0.875rem;
    color: #1e40af;
    font-weight: 500;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.card-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
}

/* ==========================================
   Recommendation Card Styles
   ========================================== */

.recommendation-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.recommendation-card:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Priority-based left border */
.recommendation-card[data-priority="high"] {
    border-left: 4px solid #ef4444;
}

.recommendation-card[data-priority="medium"] {
    border-left: 4px solid #f59e0b;
}

.recommendation-card[data-priority="low"] {
    border-left: 4px solid #10b981;
}

.recommendation-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.recommendation-priority {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.recommendation-priority.priority-high {
    background: #fef2f2;
    color: #dc2626;
}

.recommendation-priority.priority-medium {
    background: #fffbeb;
    color: #d97706;
}

.recommendation-priority.priority-low {
    background: #f0fdf4;
    color: #059669;
}

.recommendation-type {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: capitalize;
    padding: 0.25rem 0.5rem;
    background: var(--gray-100);
    border-radius: 4px;
}

.recommendation-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

.recommendation-description {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
    margin: 0 0 1rem 0;
}

.recommendation-action {
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

.recommendation-action .btn {
    font-size: 0.875rem;
}

/* General Recommendation Styling */
.recommendation-card.general {
    border-left: 4px solid var(--primary-blue);
}

.general-insight-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.general-insight-footer i {
    color: var(--primary-blue);
}

/* General Insights (Account Level) */
.general-insight {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--primary-blue);
    overflow: hidden;
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.insight-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.insight-icon.high {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.insight-icon.medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.insight-icon.low {
    background: linear-gradient(135deg, #10b981, #059669);
}

.insight-content {
    flex: 1;
}

.insight-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.insight-description {
    color: var(--gray-700);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.insight-impact {
    color: #0369a1;
    font-size: 0.875rem;
}

.insight-badge .ai-badge {
    background: var(--primary-blue);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .accordion-header {
        padding: 0.75rem 1rem;
    }

    .accordion-title {
        font-size: 0.9rem;
    }

    .accordion-meta {
        font-size: 0.8rem;
    }

    .detail-row {
        flex-direction: column;
        gap: 1rem;
    }

    .ad-preview {
        align-self: center;
    }

    .accordion-actions {
        flex-direction: column;
    }

    .accordion-actions .btn {
        min-width: unset;
    }

    .priority-badge {
        display: none;
    }

    .accordion-right {
        gap: 0.5rem;
    }
}

/* Auth Message Styles */
.auth-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 10;
}

.auth-message i {
    font-size: 1.25rem;
}

.auth-message-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.auth-message-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.auth-message-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   REDESIGNED HEALTH SCORE SECTION
   ======================================== */

/* Clean Page Header */
.page-header-clean {
    padding: 2rem 2.5rem 1.5rem 0;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.header-left {
    flex: 1;
}

.header-right {
    flex-shrink: 0;
    min-width: 280px;
}

.page-title-clean {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.page-subtitle-clean {
    font-size: 1rem;
    color: var(--gray-600);
    font-weight: 400;
}

/* Account Selector */
.account-selector-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.selector-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.selector-label i {
    margin-right: 0.25rem;
    color: var(--primary-600);
}

.account-selector {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-900);
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.account-selector:hover {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.account-selector:focus {
    outline: none;
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.account-selector option {
    padding: 0.5rem;
}

/* Health Score Container */
.health-score-container {
    padding: 0;
    margin-bottom: 2rem;
}

.health-score-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px -10px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

.health-score-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

/* Score Main Section */
.health-score-main {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3rem;
    align-items: center;
    margin-bottom: 2.5rem;
}

/* Score Badge Large */
.score-badge-large {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.score-circle-large {
    position: relative;
    width: 120px;
    height: 120px;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.score-ring-progress {
    fill: none;
    stroke: #ffffff;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1s ease-in-out;
}

.score-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-value-large {
    font-size: 2.5rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    display: block;
}

.score-max-large {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.score-label-section {
    color: #ffffff;
}

.score-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.score-status-text {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
}

/* Quick Metrics Grid */
.quick-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.quick-metric-item {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.quick-metric-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.metric-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #ffffff;
    flex-shrink: 0;
}

.metric-content {
    flex: 1;
}

.quick-metric-item .metric-label {
    font-size: 0.875rem;
    color: #ffffff !important;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.quick-metric-item .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff !important;
}

/* Health Indicators Redesign */
.health-indicators-redesign {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.indicator-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.indicator-card:hover {
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
}

.indicator-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.indicator-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.indicator-info {
    flex: 1;
}

.indicator-label-new {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.indicator-value-new {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}

.indicator-target {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-weight: 500;
}

.indicator-target.editable-target {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-left: -0.5rem;  /* Align with KPI value above */
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
}

.indicator-target.editable-target:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-blue);
}

.indicator-status-new {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-600);
    text-align: center;
}

.indicator-card .indicator-status-new.on-target {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.indicator-card .indicator-status-new.below-target {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.indicator-card .indicator-status-new.above-target {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.indicator-card .indicator-status-new.needs-attention {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* AI Agent Status Panel */
.agent-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.agent-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 1.5rem;
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agent-status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.agent-status-badge.idle {
    background: rgba(255, 255, 255, 0.3);
}

.agent-status-badge.thinking {
    background: rgba(59, 130, 246, 0.4);
    animation: pulse 2s infinite;
}

.agent-status-badge.acting {
    background: rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

.agent-status-badge.error {
    background: rgba(239, 68, 68, 0.4);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.agent-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.agent-stat-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.75rem;
    border-radius: 8px;
}

.agent-stat-label {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.agent-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.agent-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.agent-actions button {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Agent Approval Items */
.approval-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.approval-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.approval-agent-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.approval-action-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.approval-reasoning {
    color: var(--gray-600);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.approval-details {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.approval-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.approval-detail-row:last-child {
    border-bottom: none;
}

.approval-detail-label {
    color: var(--gray-600);
    font-weight: 500;
}

.approval-detail-value {
    color: var(--gray-900);
    font-weight: 600;
}

.approval-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.3s ease;
}

.approval-actions {
    display: flex;
    gap: 0.75rem;
}

.approval-actions button {
    flex: 1;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .health-indicators-redesign {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .health-score-main {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .quick-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .health-indicators-redesign {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .health-score-container {
        padding: 0 1rem 1.5rem;
    }

    .health-score-card {
        padding: 1.5rem;
    }

    .score-badge-large {
        flex-direction: column;
        text-align: center;
    }

    .quick-metrics-grid {
        grid-template-columns: 1fr;
    }

    .health-indicators-redesign {
        grid-template-columns: 1fr;
    }

    .page-header-clean {
        padding: 1.5rem 1rem 1rem;
    }

    .page-title-clean {
        font-size: 1.5rem;
    }
}

/* Animation for score ring */
@keyframes fillScoreRing {
    from {
        stroke-dashoffset: 339.292;
    }
    to {
        stroke-dashoffset: var(--score-offset);
    }
}

/* ==========================================
   Top Ads by Objective - Card Layout
   ========================================== */

.top-ad-card {
    display: flex;
    align-items: stretch;
    gap: 1.5rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 1rem;
    position: relative;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
}

.top-ad-card:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.top-ad-card.best-performer {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.top-ad-card.best-performer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 12px 12px 0 0;
}

/* Rank Badge */
.rank-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    z-index: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
}

.rank-badge.rank-4,
.rank-badge.rank-5 {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

/* Ad Card Preview (Left Side) */
.ad-card-preview {
    flex-shrink: 0;
    width: 168px;
    height: 250px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    position: relative;
}

/* Video Badge for Video Ads */
.video-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-badge i {
    font-size: 10px;
}

.ad-preview-frame-small {
    width: 168px;
    height: 250px;
    overflow: hidden;
    position: relative;
}

.ad-preview-frame-small iframe {
    width: 335px;
    height: 800px;
    border: none;
    transform: scale(0.5);
    transform-origin: top left;
    pointer-events: auto;
}

/* KPIs Section (Right Side) */
.ad-card-kpis {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ad-card-header {
    margin-bottom: 0.75rem;
}

.ad-card-header .ad-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-card-header .campaign-name {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Primary KPI - Large Display */
.primary-kpi {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 8px;
}

.primary-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.primary-kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.kpi-item {
    text-align: center;
    padding: 0.5rem 0.25rem;
    background: var(--gray-50);
    border-radius: 6px;
}

.kpi-item .kpi-value {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-900);
}

.kpi-item .kpi-label {
    display: block;
    font-size: 0.625rem;
    color: var(--gray-500);
    text-transform: uppercase;
    margin-top: 0.125rem;
}

/* View Ad Link */
.view-ad-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
    margin-top: auto;
    padding: 0.5rem 0;
    transition: color 0.2s ease;
}

.view-ad-link:hover {
    color: var(--primary-dark);
}

.view-ad-link i {
    font-size: 0.625rem;
}

/* Responsive for Top Ad Cards */
@media (max-width: 768px) {
    .top-ad-card {
        flex-direction: column;
        gap: 1rem;
    }

    .ad-card-preview {
        width: 168px;
        height: 250px;
    }

    .ad-preview-frame-small {
        width: 168px;
        height: 250px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Brand User Navigation Restrictions - Prevents flash of active nav items */
/* Brand users can access Meta Ads Manager (view-only) but not Google Ads Manager */
body.brand-user-role a[href="google-ads-manager.html"] {
    opacity: 0.5 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* Hide Analyze Now button for brand users - they use cached recommendations */
body.brand-user-role #analyzeNowContainer {
    display: none !important;
}

/* ========================================
   RESPONSIVE DESIGN - Meta Ads Manager
   ======================================== */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.mobile-menu-toggle i {
    font-size: 1.25rem;
    color: var(--gray-700);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

/* Large Desktop (1400px+) - Full layout */
@media (min-width: 1401px) {
    .sidebar {
        width: 280px;
    }
    .main-content {
        margin-left: 280px;
    }
}

/* Desktop (1200px - 1400px) - Slightly narrower sidebar */
@media (max-width: 1400px) and (min-width: 1025px) {
    .sidebar {
        width: 250px;
    }
    .main-content {
        margin-left: 250px;
        padding: 1.5rem;
    }
    .sidebar-logo {
        height: 80px;
    }
}

/* Tablet (768px - 1024px) - Collapsible sidebar */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
        padding-top: 4.5rem;
    }

    .page-header-redesigned {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .health-score-main {
        grid-template-columns: 1fr;
    }

    .quick-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .performance-comparison {
        grid-template-columns: 1fr;
    }

    .comparison-divider {
        display: none;
    }

    .goals-overview-grid {
        grid-template-columns: 1fr;
    }

    /* AI Analyst - Tablet */
    .metric-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .accordion-actions {
        flex-wrap: wrap;
    }

    .accordion-actions .btn {
        flex: 1 1 45%;
        min-width: 120px;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
        padding-top: 4rem;
    }

    .page-header-redesigned h1 {
        font-size: 1.5rem;
    }

    .page-header-actions {
        gap: 0.5rem;
    }

    .page-header-actions .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .account-selector-redesigned {
        flex-direction: column;
        align-items: stretch;
    }

    .account-selector-redesigned select {
        width: 100%;
    }

    .date-range-selector {
        flex-direction: column;
        gap: 0.5rem;
    }

    .date-range-selector select,
    .date-range-selector input {
        width: 100%;
    }

    .quick-metrics-grid,
    .campaign-metrics-grid,
    .ad-metrics-compact {
        grid-template-columns: 1fr;
    }

    .health-indicators-redesign {
        grid-template-columns: 1fr;
    }

    .metric-card,
    .health-indicator-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .top-ad-card {
        flex-direction: column;
        gap: 1rem;
    }

    .ad-card-preview {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

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

    /* AI Recommendations Section */
    .recommendation-card {
        padding: 1rem;
    }

    .recommendation-actions {
        flex-direction: column;
    }

    .recommendation-actions .btn {
        width: 100%;
    }

    /* Accordion Styles */
    .accordion-header {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .accordion-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .accordion-title {
        font-size: 0.9rem;
    }

    .accordion-meta {
        font-size: 0.75rem;
    }

    .accordion-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }

    .rec-icon-small {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .priority-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    /* Accordion Body */
    .accordion-body {
        padding: 0.75rem;
    }

    .rec-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .rec-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .rec-title {
        font-size: 1rem;
    }

    .rec-badges {
        flex-wrap: wrap;
    }

    /* Metric Cards in Recommendations */
    .metric-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .metric-cards-grid .metric-card {
        padding: 0.625rem;
    }

    .metric-cards-grid .metric-value {
        font-size: 1rem;
    }

    .metric-cards-grid .metric-label {
        font-size: 0.65rem;
    }

    /* Diagnosis Timeline */
    .diagnosis-timeline {
        gap: 0.375rem;
    }

    .diagnosis-item {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .diagnosis-icon {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .diagnosis-content h4 {
        font-size: 0.8rem;
    }

    .diagnosis-content p {
        font-size: 0.75rem;
    }

    /* Insight Sections */
    .insight-section,
    .general-insight {
        padding: 0.75rem;
    }

    .insight-section h4,
    .general-insight h4 {
        font-size: 0.85rem;
    }

    .insight-section p,
    .general-insight p {
        font-size: 0.8rem;
    }

    /* Action Buttons */
    .accordion-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .accordion-actions .btn {
        min-width: unset;
        width: 100%;
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Impact Section */
    .impact-compact {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }

    .savings-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* Agent Info */
    .agent-trigger-info {
        padding: 0.5rem 0.75rem;
    }

    .agent-badge {
        font-size: 0.75rem;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: 90vh;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Next Steps */
    .next-steps-list {
        padding-left: 1rem;
    }

    .next-steps-list li {
        font-size: 0.8rem;
        margin-bottom: 0.375rem;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .mobile-menu-toggle {
        top: 0.5rem;
        left: 0.5rem;
        padding: 0.5rem;
    }

    .main-content {
        padding: 0.75rem;
        padding-top: 3.5rem;
    }

    .page-header-redesigned h1 {
        font-size: 1.25rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .metric-card {
        padding: 0.75rem;
    }

    .metric-value {
        font-size: 1.1rem;
    }

    .metric-label {
        font-size: 0.7rem;
    }

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

    .page-header-actions .btn span {
        display: none;
    }

    .page-header-actions .btn i {
        margin-right: 0;
    }

    /* AI Analyst - Extra Small */
    .accordion-header {
        padding: 0.625rem;
    }

    .accordion-title {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .accordion-meta {
        font-size: 0.7rem;
    }

    .rec-icon-small {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .priority-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }

    .accordion-body {
        padding: 0.5rem;
    }

    .rec-icon {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .rec-title {
        font-size: 0.9rem;
    }

    .rec-badges {
        gap: 0.25rem;
    }

    .ai-badge, .ad-age-badge, .general-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.5rem;
    }

    .metric-cards-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.375rem;
    }

    .metric-cards-grid .metric-card {
        padding: 0.5rem;
    }

    .metric-cards-grid .metric-value {
        font-size: 0.9rem;
    }

    .metric-cards-grid .metric-label {
        font-size: 0.6rem;
    }

    .diagnosis-icon {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }

    .diagnosis-content h4 {
        font-size: 0.75rem;
    }

    .diagnosis-content p {
        font-size: 0.7rem;
    }

    .insight-section,
    .general-insight {
        padding: 0.5rem;
    }

    .insight-section h4,
    .general-insight h4 {
        font-size: 0.75rem;
    }

    .insight-section p,
    .general-insight p {
        font-size: 0.7rem;
        line-height: 1.4;
    }

    .accordion-actions .btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .accordion-actions .btn i {
        font-size: 0.7rem;
    }

    /* Hide text on very small screens, show only icons */
    .accordion-actions .btn span.btn-text {
        display: none;
    }

    .next-steps-list li {
        font-size: 0.7rem;
    }

    /* Override min-width constraints for narrow viewports */
    .header-right {
        min-width: unset !important;
        width: 100%;
    }

    .auth-card {
        min-width: unset;
        width: 100%;
        padding: 1.5rem;
    }

    .quick-stat {
        min-width: unset;
    }

    .top-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-right {
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        justify-content: flex-end;
    }

    .nav-actions {
        flex-wrap: wrap;
    }
}

/* ========================================
   AI Analyst Panel Responsive Overrides
   (Override inline styles with !important)
   ======================================== */

/* Tablet and below - AI Analyst header */
@media (max-width: 1024px) {
    #agentStatusPanel .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        padding: 1.25rem !important;
    }

    #analyzeNowContainer {
        width: 100% !important;
    }

    #analyzeNowBtn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Mobile - AI Analyst header */
@media (max-width: 768px) {
    #agentStatusPanel .card-header {
        padding: 1rem !important;
    }

    #agentStatusPanel .card-header h3 {
        font-size: 1.1rem !important;
    }

    #agentStatusPanel .card-header p {
        font-size: 0.8rem !important;
    }

    #analyzeNowBtn {
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
    }

    #agentStatusContainer {
        padding: 1rem !important;
    }

    #agentStatusContainer > div {
        padding: 2rem 1rem !important;
    }
}

/* Small Mobile - AI Analyst header */
@media (max-width: 480px) {
    #agentStatusPanel .card-header {
        padding: 0.75rem !important;
    }

    #agentStatusPanel .card-header h3 {
        font-size: 1rem !important;
    }

    #agentStatusPanel .card-header p {
        font-size: 0.75rem !important;
    }

    #analyzeNowBtn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    #agentStatusContainer {
        padding: 0.75rem !important;
    }

    #agentStatusContainer > div {
        padding: 1.5rem 0.75rem !important;
    }
}

/* ========================================
   Quick Metrics & Health Score Responsive
   ======================================== */

@media (max-width: 1024px) {
    .health-score-container {
        padding: 0 1rem 1.5rem;
    }

    .health-score-card {
        padding: 1.5rem;
    }

    .quick-metric-item {
        padding: 1rem;
    }

    .metric-icon-wrap {
        width: 40px;
        height: 40px;
    }

    .metric-icon-wrap i {
        font-size: 1rem;
    }

    .quick-metric-item .metric-value {
        font-size: 1.25rem;
    }

    .indicator-card {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .health-score-container {
        padding: 0 0.75rem 1rem;
    }

    .health-score-card {
        padding: 1rem;
        border-radius: 12px;
    }

    .score-badge-large {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .score-circle-large {
        width: 100px;
        height: 100px;
    }

    .score-value-large {
        font-size: 2rem;
    }

    .score-max-large {
        font-size: 0.875rem;
    }

    .score-title {
        font-size: 1rem;
    }

    .quick-metric-item {
        padding: 0.875rem;
        border-radius: 12px;
    }

    .metric-icon-wrap {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .metric-icon-wrap i {
        font-size: 0.875rem;
    }

    .quick-metric-item .metric-label {
        font-size: 0.75rem;
    }

    .quick-metric-item .metric-value {
        font-size: 1.1rem;
    }

    .indicator-card {
        padding: 0.875rem;
        border-radius: 12px;
    }

    .indicator-icon-box {
        width: 36px;
        height: 36px;
    }

    .indicator-label-new {
        font-size: 0.75rem;
    }

    .indicator-value-new {
        font-size: 1.1rem;
    }

    .indicator-target {
        font-size: 0.7rem;
    }

    .indicator-status-new {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .health-score-container {
        padding: 0 0.5rem 0.75rem;
    }

    .health-score-card {
        padding: 0.75rem;
    }

    .score-circle-large {
        width: 80px;
        height: 80px;
    }

    .score-value-large {
        font-size: 1.5rem;
    }

    .score-max-large {
        font-size: 0.75rem;
    }

    .score-title {
        font-size: 0.875rem;
    }

    .score-status-text {
        font-size: 0.75rem;
    }

    .quick-metric-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .metric-icon-wrap {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .metric-icon-wrap i {
        font-size: 0.75rem;
    }

    .quick-metric-item .metric-label {
        font-size: 0.7rem;
    }

    .quick-metric-item .metric-value {
        font-size: 1rem;
    }

    .indicator-card {
        padding: 0.75rem;
    }

    .indicator-icon-box {
        width: 32px;
        height: 32px;
    }

    .indicator-icon-box i {
        font-size: 0.75rem;
    }

    .indicator-label-new {
        font-size: 0.7rem;
    }

    .indicator-value-new {
        font-size: 1rem;
    }

    .indicator-target {
        font-size: 0.65rem;
    }

    .indicator-status-new {
        font-size: 0.65rem;
    }
}