/* AuraMail Light Theme: Crisp, Modern & Clean UI (Zero/Minimal Gradients) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-soft: #f1f5f9;
    --color-border: #e2e8f0;
    --color-border-subtle: #f1f5f9;
    --color-primary: #0284c7;
    --color-primary-hover: #0369a1;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-success: #10b981;
    --color-amber: #f59e0b;
    --color-danger: #ef4444;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Universal Overflow Prevention Safeguards */
*, ::before, ::after {
    box-sizing: border-box;
}

select, input, textarea {
    max-width: 100%;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

code, pre, .font-mono {
    font-family: var(--font-mono);
}

/* Custom Sleek Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Editor Styling */
.email-editor-content {
    outline: none;
    min-height: 280px;
    padding: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #1e293b;
    background-color: #ffffff;
}

.email-editor-content:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
    cursor: text;
}

/* Fullscreen Editor Mode */
.editor-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    margin: 0 !important;
    background: #ffffff !important;
}
.editor-fullscreen .email-editor-content {
    min-height: calc(100vh - 280px) !important;
}

/* Recipient Tag Pill */
.recipient-pill {
    display: inline-flex;
    align-items: center;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    margin: 0.125rem;
    transition: all 0.15s ease;
}

.recipient-pill.invalid {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.recipient-pill .remove-pill,
.recipient-pill button {
    margin-left: 0.35rem;
    cursor: pointer;
    color: #64748b;
    font-weight: bold;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
}
.recipient-pill.invalid .remove-pill,
.recipient-pill.invalid button {
    color: #dc2626;
}

.recipient-pill .remove-pill:hover,
.recipient-pill button:hover {
    color: #0f172a;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    font-size: 0.8125rem;
    font-weight: 500;
    animation: toast-slide 0.25s ease forwards;
    max-width: 24rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

@keyframes toast-slide {
    from {
        transform: translateY(1rem);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Sidebar Collapsible Mode */
#app-sidebar.sidebar-collapsed {
    width: 4.5rem !important; /* 72px */
}

#app-sidebar.sidebar-collapsed .sidebar-text,
#app-sidebar.sidebar-collapsed .sidebar-header-badge,
#app-sidebar.sidebar-collapsed .sidebar-section-title,
#app-sidebar.sidebar-collapsed .sidebar-user-details {
    display: none !important;
}

#app-sidebar.sidebar-collapsed .sidebar-nav-link {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

#app-sidebar.sidebar-collapsed .sidebar-brand-link {
    justify-content: center !important;
}

#app-sidebar.sidebar-collapsed .sidebar-compose-cta {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

#app-sidebar.sidebar-collapsed .sidebar-compose-cta span {
    display: none !important;
}

#app-sidebar.sidebar-collapsed .sidebar-user-container {
    justify-content: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

#app-sidebar.sidebar-collapsed .sidebar-logout-btn {
    display: none !important;
}

/* Mobile Responsive Safeguards & No-Overflow Rules */
html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
    width: 100% !important;
}

*, ::before, ::after {
    box-sizing: border-box;
}

select, input, textarea, button {
    max-width: 100%;
    min-width: 0;
}

select {
    text-overflow: ellipsis;
}

.min-w-0 {
    min-width: 0 !important;
}

.max-w-full {
    max-width: 100% !important;
}

.overflow-x-auto, [class*="overflow-x-"] {
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
}

@media (max-width: 640px) {
    /* Prevent table wrappers and wide blocks from blowing out mobile viewport */
    .overflow-x-auto, [class*="overflow-x-"] {
        max-width: 100% !important;
    }

    /* Container constraints */
    .max-w-7xl, .max-w-5xl, .max-w-4xl, .max-w-3xl, .max-w-2xl, .max-w-xl, .max-w-lg, .max-w-md {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Modals fit small screens with nice breathing room */
    #schedule-modal > div, #preview-modal > div, #add-smtp-modal > div, #save-template-modal > div {
        max-width: calc(100vw - 1.25rem) !important;
        width: 100% !important;
        margin: 0.5rem auto !important;
    }

    /* Long words / URLs wrap cleanly, but never break table headers into vertical letters */
    p, span, h1, h2, h3, h4, h5, h6, a, td {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    th {
        white-space: nowrap !important;
        overflow-wrap: normal !important;
        word-break: normal !important;
    }

    code, pre {
        word-break: break-all;
        overflow-wrap: anywhere;
        white-space: pre-wrap;
    }

    /* Rich text editor content */
    .email-editor-content {
        word-break: break-word;
        overflow-wrap: anywhere;
        min-height: 200px !important;
        padding: 0.75rem !important;
    }

    /* Fix template and select inputs on small screens */
    select {
        font-size: 12px !important;
    }

    /* Form controls take up natural responsive widths */
    input[type="text"], input[type="email"], input[type="password"], select {
        font-size: 13px;
    }
}