/* App-specific styles. Utility styling comes from Tailwind classes in views. */
.sidebar {
    transition: transform 0.2s ease-in-out;
}

.swal2-popup {
    font-family: inherit;
}

/* HTML source editor: transparent textarea over a highlighted <pre>. */
.code-editor {
    position: relative;
    height: 20rem;
    overflow: hidden;
    border: 1px solid #10534d;
    border-radius: 0.375rem;
    background: #06272b;
}
.code-editor:focus-within {
    border-color: #278460;
    box-shadow: 0 0 0 2px rgba(138, 191, 152, 0.5);
}
.code-editor.has-error {
    border-color: #f87171;
}
.code-editor pre,
.code-editor textarea {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 0.75rem;
    border: 0;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0;
    white-space: pre;
    overflow-wrap: normal;
    tab-size: 2;
}
.code-editor pre {
    overflow: hidden;
    pointer-events: none;
    color: #e2e8f0;
}
.code-editor textarea {
    z-index: 1;
    width: 100%;
    height: 100%;
    overflow: auto;
    resize: none;
    outline: none;
    color: #e2e8f0;
    background: transparent;
    caret-color: #ffffff;
}
.code-editor.is-highlighted textarea {
    color: transparent;
}
.code-editor.is-highlighted textarea::selection {
    color: transparent;
    background: rgba(138, 191, 152, 0.35);
}
.tok-tag { color: #8abf98; }
.tok-attr { color: #7dd3fc; }
.tok-value { color: #fcd34d; }
.tok-punct { color: #9fbdb8; }
.tok-comment { color: #7a9e98; font-style: italic; }
.tok-placeholder { color: #06272b; background: #8abf98; border-radius: 2px; }

.preview-frame {
    width: 100%;
    min-height: 20rem;
    flex: 1;
    border: 1px solid #d3e5d9;
    border-radius: 0.375rem;
    background: #ffffff;
}

/* Larger editor/preview from tablet width up (mobile-first). */
@media (min-width: 768px) {
    .code-editor { height: 32rem; }
    .preview-frame { min-height: 32rem; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

/* Visual block editor (templates/builder). */
.preview-stage {
    display: flex;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    background: #eef6f1;
}
.preview-stage .preview-frame {
    min-height: 32rem;
    transition: width 0.2s ease;
}
.preview-stage .preview-frame.is-mobile {
    width: 375px;
    max-width: 100%;
    flex: none;
}
.block-item.is-selected > .block-row {
    border-color: #278460;
    box-shadow: 0 0 0 2px rgba(138, 191, 152, 0.5);
}
.block-item.is-dragging { opacity: 0.4; }
.block-item.is-drop-target > .block-row { border-top: 3px solid #278460; }
.rich-editor {
    min-height: 8rem;
    max-height: 24rem;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0 0 0.375rem 0.375rem;
    font-size: 0.875rem;
    line-height: 1.6;
    outline: none;
}
.rich-editor:focus { border-color: #278460; box-shadow: 0 0 0 2px rgba(138, 191, 152, 0.5); }
.rich-editor p { margin: 0 0 0.5rem; }
.rich-editor ul { list-style: disc; padding-left: 1.5rem; }
.rich-editor ol { list-style: decimal; padding-left: 1.5rem; }
.rich-editor a { color: #278460; text-decoration: underline; }
.media-thumb {
    width: 100%;
    height: 6rem;
    object-fit: contain;
    background: #eef6f1;
}

@media (prefers-reduced-motion: reduce) {
    .preview-stage .preview-frame { transition: none; }
}

/* Branding (tuyuMail). Logos are the supplied PNGs, scaled by height/width only (aspect ratio kept). */
.brand-link {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    border-radius: 0.375rem;
}
.brand-link:focus-visible { outline: 2px solid #8abf98; outline-offset: 2px; }
.brand-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
}
.brand-logo-sidebar { height: 2.75rem; }          /* 44px in the 64px sidebar header (~132px wide) */
.brand-logo-login { width: 15rem; height: auto; }  /* 240px wide on the login page */
.app-footer {
    font-size: 0.75rem;
    line-height: 1.25rem;
    color: #64748b;
}

/* Phase 10: dashboard, live progress, charts. Transitions only when values change; none with reduced motion. */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
}
.live-badge[data-state="active"] { background: #eef6f1; color: #10534d; }
.live-dot { width: 0.5rem; height: 0.5rem; border-radius: 9999px; background: #94a3b8; }
.live-badge[data-state="active"] .live-dot { background: #278460; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.stat-card, .stat-tile { transition: box-shadow 0.3s ease, background-color 0.6s ease; }
.stat-tile.is-updated, .status-pill.is-updated, [data-row-status].is-updated { animation: value-flash 1.2s ease-out; }
@keyframes value-flash { 0% { background-color: #d3e5d9; } 100% { background-color: transparent; } }
[data-stat].is-changing { color: #278460; }

.progress-track {
    height: 0.5rem;
    overflow: hidden;
    border-radius: 9999px;
    background: #e2e8f0;
}
.progress-track-lg { height: 0.875rem; }
.progress-fill {
    width: 0;
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #278460, #8abf98);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.status-pill {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
}
.status-pill[data-status="queued"], .status-pill[data-status="sending"] { background: #278460; color: #fff; }
.status-pill[data-status="completed"] { background: #d3e5d9; color: #10534d; }
.status-pill[data-status="cancelled"] { background: #fee2e2; color: #b91c1c; }

.range-btn { background: #fff; }
.range-btn:hover { background: #eef6f1; }
.range-btn[aria-pressed="true"] { background: #278460; border-color: #278460; color: #fff; }

.chart-box { position: relative; width: 100%; min-height: 220px; }
.chart-svg { display: block; overflow: visible; }
.chart-grid { stroke: #e2e8f0; stroke-width: 1; }
.chart-axis { fill: #64748b; font-size: 11px; }
.chart-bar { cursor: pointer; }
.chart-bar:hover rect:not([fill="transparent"]) { opacity: 0.85; }
.chart-tip {
    position: absolute;
    z-index: 10;
    min-width: 9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
    background: #06272b;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.3;
    pointer-events: none;
}
.legend-swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; }

.queue-bar { display: flex; height: 0.875rem; overflow: hidden; border-radius: 9999px; background: #e2e8f0; }
.queue-seg { height: 100%; transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.recent-card { transition: border-color 0.4s ease, background-color 0.4s ease; }

@media (prefers-reduced-motion: reduce) {
    .live-badge[data-state="active"] .live-dot { animation: none; }
    .progress-fill, .queue-seg, .stat-card, .stat-tile, .recent-card { transition: none; }
    .stat-tile.is-updated, .status-pill.is-updated, [data-row-status].is-updated { animation: none; }
}

/* Collapsible recipient list (campaign page) */
.rcp-chevron { display: inline-block; transition: transform .15s ease; }
[data-rcp-toggle][aria-expanded="true"] .rcp-chevron { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .rcp-chevron { transition: none; } }

/* Dashboard update card (update-check.js sets data-state) */
.update-card { border-left: 4px solid transparent; }
.update-card[data-state="available"] { border-left-color: #278460; }
.update-card[data-state="current"] { border-left-color: #8ABF98; }
.update-card[data-state="blocked"],
.update-card[data-state="failed"] { border-left-color: #d97706; }
