/* ==========================================================================
   UI Kit — Unified Design System Enhancements
   ==========================================================================
   Adds: mobile table cards, loading skeletons, toast notifications,
   improved empty/error states, focus indicators, print styles, animations.
   Breakpoints: 360px / 576px / 768px / 992px / 1200px / 1400px
   ========================================================================== */

/* ── Unified Design Tokens (override + extend) ─────────── */
:root {
    --color-academic-navy: #1a3a5c;
    --color-academic-blue: #2c5f8a;
    --color-academic-gold: #c8a951;
    --focus-ring: 0 0 0 3px rgba(26,58,92,0.25);
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.25s cubic-bezier(0.4,0,0.2,1);
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06),0 1px 2px rgba(0,0,0,0.04);
    --shadow-elevated: 0 10px 30px rgba(0,0,0,0.1),0 4px 8px rgba(0,0,0,0.06);
    --shadow-modal: 0 20px 60px rgba(0,0,0,0.2);
}

/* ── Focus Ring (global) ─────────────────────────────── */
*:focus-visible {
    outline: 2px solid var(--color-academic-navy);
    outline-offset: 2px;
    border-radius: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--color-academic-navy);
    outline-offset: 1px;
}
/* Remove default focus when using mouse */
*:focus:not(:focus-visible) { outline: none; }

/* ── Responsive Table → Card Layout (mobile) ──────────── */
@media (max-width: 767px) {
    .table--responsive thead { display: none; }
    .table--responsive tbody, .table--responsive tr, .table--responsive td { display: block; }
    .table--responsive tr {
        background: var(--color-bg); border: 1px solid var(--color-border-light);
        border-radius: var(--radius-sm); margin-bottom: var(--spacing-sm); padding: var(--spacing-sm);
    }
    .table--responsive td {
        display: flex; justify-content: space-between; align-items: center;
        padding: var(--spacing-xs) 0; border-bottom: 1px solid var(--color-border-light);
        font-size: var(--font-size-sm);
    }
    .table--responsive td:last-child { border-bottom: none; justify-content: flex-end; }
    .table--responsive td::before {
        content: attr(data-label); font-weight: var(--font-weight-semibold);
        color: var(--color-text-secondary); font-size: var(--font-size-xs);
        text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0; margin-right: var(--spacing-md);
    }
}

/* ── Loading Skeleton ─────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%; animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton--text { height: 16px; margin-bottom: 8px; width: 100%; }
.skeleton--text--short { width: 60%; }
.skeleton--title { height: 24px; margin-bottom: 12px; width: 80%; }
.skeleton--avatar { width: 48px; height: 48px; border-radius: 50%; }
.skeleton--card { height: 120px; width: 100%; margin-bottom: 16px; }
.skeleton--btn { height: 40px; width: 120px; border-radius: var(--radius-sm); }
.skeleton--row { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ── Toast Notifications ──────────────────────────────── */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px; max-width: 400px;
}
.toast {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-elevated);
    animation: toast-in 0.3s var(--transition-smooth); font-size: var(--font-size-sm);
    border-left: 4px solid transparent; min-width: 300px;
}
.toast--success { background: #ecfdf5; border-left-color: #10b981; color: #065f46; }
.toast--error   { background: #fef2f2; border-left-color: #ef4444; color: #991b1b; }
.toast--warning { background: #fffbeb; border-left-color: #f59e0b; color: #92400e; }
.toast--info    { background: #eff6ff; border-left-color: #3b82f6; color: #1e40af; }
.toast__icon { font-size: 1.25rem; flex-shrink: 0; }
.toast__content { flex: 1; }
.toast__title { font-weight: 600; display: block; margin-bottom: 2px; }
.toast__close { background: none; border: none; font-size: 1.25rem; cursor: pointer; opacity: 0.5; padding: 0; line-height: 1; }
.toast__close:hover { opacity: 1; }
.toast--leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(100%); } }

/* ── Improved Empty State ─────────────────────────────── */
.empty-state {
    text-align: center; padding: var(--spacing-3xl) var(--spacing-lg);
    background: var(--color-bg); border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
}
.empty-state__icon { font-size: 3rem; margin-bottom: var(--spacing-md); display: block; }
.empty-state__title { font-size: var(--font-size-lg); color: var(--color-text); margin-bottom: var(--spacing-sm); }
.empty-state__text { color: var(--color-text-secondary); margin-bottom: var(--spacing-lg); max-width: 400px; margin-left: auto; margin-right: auto; }
.empty-state--inline { padding: var(--spacing-xl); }

/* ── Error State ──────────────────────────────────────── */
.error-state {
    text-align: center; padding: var(--spacing-2xl);
    background: var(--color-danger-light); border: 2px solid var(--color-danger);
    border-radius: var(--radius-md); color: var(--color-danger);
}
.error-state__icon { font-size: 2.5rem; margin-bottom: var(--spacing-sm); }
.error-state__title { font-weight: 600; margin-bottom: var(--spacing-sm); }
.error-state__text { font-size: var(--font-size-sm); margin-bottom: var(--spacing-md); }

/* ── Spinner ──────────────────────────────────────────── */
.spinner {
    display: inline-block; width: 24px; height: 24px;
    border: 3px solid var(--color-border); border-top-color: var(--color-academic-navy);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 40px; height: 40px; border-width: 4px; }
.spinner--white { border-color: rgba(255,255,255,0.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading Overlay ──────────────────────────────────── */
.loading-overlay {
    position: absolute; inset: 0; background: rgba(255,255,255,0.8);
    display: flex; align-items: center; justify-content: center;
    border-radius: inherit; z-index: 10;
}

/* ── Button Enhancements ──────────────────────────────── */
.btn { transition: all var(--transition-fast); position: relative; }
.btn:active { transform: scale(0.97); }
.btn--loading { pointer-events: none; color: transparent !important; }
.btn--loading::after {
    content: ''; position: absolute; width: 18px; height: 18px;
    border: 2px solid currentColor; border-top-color: transparent;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.btn--icon { padding: 0.5rem; min-width: 36px; min-height: 36px; justify-content: center; }
.btn--success { background: var(--color-success); color: #fff; }
.btn--success:hover { background: #0b8553; }

/* ── Status Timeline (Enhanced) ────────────────────────── */
.timeline {
    position: relative; padding-left: 28px;
}
.timeline::before {
    content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px;
    width: 2px; background: var(--color-border);
}
.timeline__item {
    position: relative; padding-bottom: var(--spacing-lg);
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
    content: ''; position: absolute; left: -21px; top: 6px;
    width: 12px; height: 12px; border-radius: 50%; background: var(--color-border);
    border: 2px solid var(--color-bg); z-index: 1;
}
.timeline__item--active::before { background: var(--color-academic-navy); }
.timeline__item--done::before { background: var(--color-success); }
.timeline__item--current::before { background: var(--color-academic-blue); box-shadow: 0 0 0 3px rgba(44,95,138,0.25); }
.timeline__item__time { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.timeline__item__title { font-weight: 600; font-size: var(--font-size-sm); }
.timeline__item__body { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin-top: 2px; }

/* ── Print Stylesheet ─────────────────────────────────── */
@media print {
    .site-header, .site-footer, .trust-bar, .search-bar, .nav, .btn,
    .sidebar, .topbar, .admin-main .topbar, .flash, .pagination,
    .article-detail__sidebar, .share-buttons, .skip-link { display: none !important; }
    body { font-size: 11pt; color: #000; background: #fff; }
    .container { max-width: 100%; padding: 0; }
    .article-detail__grid { grid-template-columns: 1fr; }
    .article-detail__title { font-size: 16pt; }
    .article-section__title { font-size: 12pt; border-bottom: 1px solid #000; }
    .badge { border: 1px solid #000 !important; background: none !important; color: #000 !important; }
    a { color: #000; text-decoration: underline; }
    .retraction-banner { border: 2px solid #000; background: #eee; }
    @page { margin: 2cm; }
}

/* ── High Contrast / Reduced Motion ────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-contrast: high) {
    :root { --color-border: #666; --color-text: #000; --color-text-secondary: #333; }
    .badge, .table td, .card { border: 1px solid #666; }
}

/* ── Step Indicator (compact mobile variant) ───────────── */
@media (max-width: 480px) {
    .wizard-progress--9steps .wizard-progress__label { display: none; }
    .wizard-progress__connector { width: 8px; }
}

/* ── Dashboard Card Hover ─────────────────────────────── */
.card--hoverable { transition: box-shadow var(--transition-fast), transform var(--transition-fast); }
.card--hoverable:hover { box-shadow: var(--shadow-elevated); transform: translateY(-1px); }

/* ── Inline Code ──────────────────────────────────────── */
code, .code {
    font-family: 'SF Mono','Fira Code','Cascadia Code',monospace;
    font-size: 0.85em; background: #f1f5f9; padding: 1px 5px;
    border-radius: 3px; color: #334155;
}

/* ── Page transition (subtle) ──────────────────────────── */
.site-main { animation: page-in 0.2s var(--transition-smooth); }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive Container Padding ─────────────────────── */
@media (max-width: 480px) {
    .container { padding: 0 var(--spacing-sm); }
    .wizard-card { padding: var(--spacing-md); }
    .auth-card { padding: var(--spacing-lg); max-width: 100%; }
}
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* ── Tablet Optimizations ──────────────────────────────── */
@media (min-width: 768px) and (max-width: 991px) {
    .submission-detail-grid, .article-detail__grid, .payment-grid,
    .content-block__grid, .submit-grid, .contact-grid { grid-template-columns: 1fr; }
    .submission-detail-sidebar { position: static; }
}
