:root {
    --primary: #5022C3;
    --secondary: #7155EF;
    --light: #F2EEFE;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #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;
}

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

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: #3d1a9e;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--secondary);
    color: white;
    transition: all 0.2s ease;
}

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

.btn-danger {
    background-color: var(--danger);
    color: white;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar {
    background: white;
    border-right: 1px solid var(--gray-200);
    transition: width 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 40;
    overflow-y: auto;
}

.main-content {
    margin-left: 256px;
    min-height: 100vh;
    overflow-y: auto;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 72px;
}

/* Collapsed sidebar styles */
.sidebar.collapsed {
    width: 72px;
}

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

.sidebar.collapsed .sidebar-header {
    padding: 1.5rem 1rem;
    justify-content: center;
}

.sidebar.collapsed .sidebar-header > div {
    justify-content: center;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed nav {
    padding: 1rem 0.75rem;
}

.sidebar.collapsed .p-4 {
    padding: 1rem 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--gray-600);
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: var(--light);
    color: var(--primary);
}

.sidebar-link.active {
    background: var(--light);
    color: var(--primary);
    font-weight: 500;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 100;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

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

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--danger);
}

.notification.warning {
    background: var(--warning);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.published,
.status-badge.active {
    background: #D1FAE5;
    color: #065F46;
}

.status-badge.draft,
.status-badge.inactive {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-badge.in_review {
    background: #FEF3C7;
    color: #D97706;
}

.status-badge.canceled {
    background: #FEE2E2;
    color: #991B1B;
}

.status-badge.expired {
    background: #FEE2E2;
    color: #991B1B;
}

.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(80, 34, 195, 0.1);
}

.table-row {
    transition: background 0.2s ease;
}

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

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

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Rich text content styling - reset Quill generated paragraph margins */
.prose p,
.rich-text-content p,
#preview-content p,
.email-template p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.6 !important;
}

/* Add spacing only between consecutive paragraphs with actual content */
.prose p + p,
.rich-text-content p + p,
#preview-content p + p {
    margin-top: 0.25em !important;
}

.prose p:last-child,
.rich-text-content p:last-child,
#preview-content p:last-child,
.email-template p:last-child {
    margin-bottom: 0 !important;
}

/* Handle truly empty paragraphs - but not intentional line breaks */
.prose p:empty,
.rich-text-content p:empty,
#preview-content p:empty,
.email-template p:empty {
    display: none !important;
}

/* Quill empty line marker class - preserves intentional line spacing */
.prose .ql-empty-line,
.rich-text-content .ql-empty-line,
#preview-content .ql-empty-line {
    display: block !important;
    height: 1.6em !important;
    margin: 0 !important;
    line-height: 1.6 !important;
}

.prose ul,
.prose ol,
.rich-text-content ul,
.rich-text-content ol,
#preview-content ul,
#preview-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.prose li,
.rich-text-content li,
#preview-content li {
    margin: 0.25em 0;
}

/* Headers within rich text content */
.prose h1,
.rich-text-content h1,
#preview-content h1 {
    font-size: 1.75em;
    font-weight: 700;
    margin: 0.75em 0 0.5em 0;
    color: var(--gray-900);
    line-height: 1.3;
}

.prose h2,
.rich-text-content h2,
#preview-content h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.75em 0 0.5em 0;
    color: var(--gray-900);
    line-height: 1.3;
}

.prose h3,
.rich-text-content h3,
#preview-content h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 0.75em 0 0.5em 0;
    color: var(--gray-800);
    line-height: 1.4;
}

.prose h4,
.rich-text-content h4,
#preview-content h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0.5em 0 0.25em 0;
    color: var(--gray-800);
    line-height: 1.4;
}

/* Remove top margin from first header */
.prose h1:first-child,
.prose h2:first-child,
.prose h3:first-child,
.prose h4:first-child,
.rich-text-content h1:first-child,
.rich-text-content h2:first-child,
.rich-text-content h3:first-child,
.rich-text-content h4:first-child,
#preview-content h1:first-child,
#preview-content h2:first-child,
#preview-content h3:first-child,
#preview-content h4:first-child {
    margin-top: 0;
}

.prose a,
.rich-text-content a,
#preview-content a {
    color: var(--primary);
    text-decoration: underline;
}

.prose a.btn-primary,
.rich-text-content a.btn-primary,
#preview-content a.btn-primary,
.prose .btn-primary,
.rich-text-content .btn-primary,
#preview-content .btn-primary {
    color: white !important;
    text-decoration: none;
}

.prose .btn-primary svg,
.rich-text-content .btn-primary svg,
#preview-content .btn-primary svg {
    color: white !important;
    stroke: white !important;
}

.prose strong,
.rich-text-content strong,
#preview-content strong {
    font-weight: 600;
}

.prose em,
.rich-text-content em,
#preview-content em {
    font-style: italic;
}

/* Quill editor wrapper styling */
.quill-wrapper {
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    overflow: hidden;
}

.quill-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(80, 34, 195, 0.1);
}

.quill-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.quill-wrapper .ql-container {
    border: none;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Preview mode styles */
.preview-mobile {
    max-width: 375px !important;
    margin: 0 auto;
    border: 8px solid #1a1a1a;
    border-radius: 32px;
    background: white;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.preview-mobile::before {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    margin: 8px auto;
}

.preview-web {
    max-width: 100%;
    background: white;
}

.preview-toggle-btn.active {
    background: var(--light);
    color: var(--primary);
}

@media (max-width: 768px) {
    .sidebar {
        left: -280px;
        width: 280px;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 30;
        display: none;
    }

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