/* ============================================================
   PostPigeon Admin Panel - Main Stylesheet
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --color-primary: #6366F1;
    --color-primary-hover: #4F46E5;
    --color-primary-light: #EEF2FF;
    --color-primary-subtle: #C7D2FE;
    --color-secondary: #8B5CF6;
    --color-secondary-hover: #7C3AED;
    --color-success: #10B981;
    --color-success-light: #D1FAE5;
    --color-success-dark: #059669;
    --color-warning: #F59E0B;
    --color-warning-light: #FEF3C7;
    --color-warning-dark: #D97706;
    --color-error: #EF4444;
    --color-error-light: #FEE2E2;
    --color-error-dark: #DC2626;
    --color-bg: #F8FAFC;
    --color-dark: #1E293B;
    --color-dark-secondary: #334155;
    --color-text: #1E293B;
    --color-text-secondary: #64748B;
    --color-text-muted: #94A3B8;
    --color-border: #E2E8F0;
    --color-border-dark: #CBD5E1;
    --color-white: #FFFFFF;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F1F5F9;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --sidebar-width: 260px;
    --header-height: 64px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* --- Reset / Normalize --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-hover);
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

table {
    border-collapse: collapse;
    width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-dark);
    color: var(--color-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sidebar-brand-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand-text small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav-section {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    user-select: none;
}

.sidebar-nav-item:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-item.active {
    color: var(--color-white);
    background: rgba(99, 102, 241, 0.15);
    border-left-color: var(--color-primary);
}

.sidebar-nav-item .nav-icon {
    width: 22px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-white);
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    padding: 4px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.sidebar-logout-btn:hover {
    color: var(--color-error);
}

/* Main Content */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: var(--header-height);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.main-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text);
    padding: 4px;
}

.header-breadcrumb {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.header-breadcrumb span {
    color: var(--color-text);
    font-weight: 600;
}

.main-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-health-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-success-light);
    color: var(--color-success-dark);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}

.header-health-badge.degraded {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.header-health-badge.down {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.main-content {
    flex: 1;
    padding: 32px;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
}

.page-header p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Cards --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card-icon.primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.stat-card-icon.success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.stat-card-icon.warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.stat-card-icon.error {
    background: var(--color-error-light);
    color: var(--color-error);
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.stat-card-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

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

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
}

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

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--color-surface-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-cell-primary {
    font-weight: 600;
    color: var(--color-text);
}

.table-cell-secondary {
    color: var(--color-text-secondary);
    font-size: 13px;
}

.table-cell-mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: var(--color-border-dark);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-white);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: var(--color-border-dark);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--color-success-dark);
}

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

.btn-warning:hover:not(:disabled) {
    background: var(--color-warning-dark);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--color-error-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 6px 10px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--color-error);
}

.form-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
    color: var(--color-text);
    font-size: 14px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-muted);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-error {
    font-size: 12px;
    color: var(--color-error);
    margin-top: 4px;
}

/* Filters bar */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-input {
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--color-white);
    color: var(--color-text);
    outline: none;
    min-width: 180px;
}

.filter-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-select {
    padding: 8px 32px 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--color-white);
    color: var(--color-text);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-success {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.badge-warning {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.badge-error {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.badge-neutral {
    background: #F1F5F9;
    color: var(--color-text-secondary);
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-queued {
    background: #F1F5F9;
    color: var(--color-text-secondary);
}

.status-processing {
    background: #DBEAFE;
    color: #2563EB;
}

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

.status-delivered {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.status-bounced {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.status-failed {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.status-draft {
    background: #F1F5F9;
    color: var(--color-text-secondary);
}

.status-published {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.status-archived {
    background: #F1F5F9;
    color: var(--color-text-muted);
}

/* Badge variants for message statuses */
.badge-queued {
    background: #F1F5F9;
    color: var(--color-text-secondary);
}

.badge-processing {
    background: #DBEAFE;
    color: #2563EB;
}

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

.badge-delivered {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.badge-bounced {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.badge-failed {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(10px) scale(0.98);
    transition: transform var(--transition-normal);
}

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

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1100px;
}

.modal-header {
    padding: 24px 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--color-text-muted);
    font-size: 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.modal-body {
    padding: 24px 28px;
}

.modal-footer {
    padding: 0 28px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 440px;
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.toast-message {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.toast.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast.toast-error {
    border-left: 4px solid var(--color-error);
}

.toast.toast-warning {
    border-left: 4px solid var(--color-warning);
}

.toast.toast-info {
    border-left: 4px solid var(--color-primary);
}

/* --- Loading --- */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: var(--color-text-secondary);
    gap: 16px;
}

.loading-state p {
    font-size: 14px;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--color-text-secondary);
    max-width: 380px;
    margin-bottom: 20px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    gap: 0;
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-item {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-item:hover {
    color: var(--color-text);
}

.tab-item.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* --- Code / Mono --- */
.code-block {
    background: var(--color-dark);
    color: #E2E8F0;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 13px;
    overflow-x: auto;
    line-height: 1.6;
}

.inline-code {
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

/* --- Detail / Key-Value --- */
.detail-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px 20px;
}

.detail-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.detail-value {
    font-size: 14px;
    color: var(--color-text);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--color-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--color-white);
    box-shadow: 0 0 0 2px var(--color-border);
    background: var(--color-white);
}

.timeline-dot.success {
    background: var(--color-success);
    box-shadow: 0 0 0 2px var(--color-success);
}

.timeline-dot.error {
    background: var(--color-error);
    box-shadow: 0 0 0 2px var(--color-error);
}

.timeline-dot.warning {
    background: var(--color-warning);
    box-shadow: 0 0 0 2px var(--color-warning);
}

.timeline-dot.info {
    background: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}

.timeline-content h4 {
    font-size: 14px;
    font-weight: 600;
}

.timeline-content p {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.timeline-time {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* --- Template Preview --- */
.preview-frame {
    width: 100%;
    min-height: 400px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
}

.editor-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.editor-section textarea {
    width: 100%;
    min-height: 300px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
    outline: none;
}

.editor-section textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Variables helper */
.variables-helper {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.variables-helper h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text-secondary);
}

.variables-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.variable-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.variable-tag:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-subtle);
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* --- Color Indicators --- */
.color-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    margin-right: 4px;
    vertical-align: middle;
}

/* --- Color Picker Group --- */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-color-input {
    width: 48px;
    height: 40px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
}

.color-picker-group .form-input:not(.form-color-input) {
    flex: 1;
}

/* --- JSON Editor --- */
.json-editor {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

/* --- Status badge suppressed --- */
.status-suppressed {
    background: #f1f5f9;
    color: #64748b;
}

/* --- Preview Container --- */
.preview-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-white);
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Quick Action Card --- */
.quick-action-card {
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.quick-action-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.quick-action-link {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
}

/* --- Responsive --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .editor-pane {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .main-content {
        padding: 20px 16px;
    }

    .main-header {
        padding: 0 16px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
