/* ============================================================
   🏛️ ПОРТАЛ АДМИНИСТРАЦИИ ДМИТРОВСКОГО МО — СТИЛИ v2.0
   ============================================================ */

:root {
    /* Блоки агентов */
    --color-admin: #1565c0;
    --color-admin-bg: #e3f2fd;
    --color-federal: #c62828;
    --color-federal-bg: #ffebee;
    --color-shadow: #e65100;
    --color-shadow-bg: #fff3e0;
    --color-civil: #2e7d32;
    --color-civil-bg: #e8f5e9;
    --color-moderator: #f9a825;
    --color-moderator-bg: #fffde7;

    /* UI */
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Session stats совместимость */
    --bg-light: #ffffff;
    --primary-color: #219ebc;
    --primary-dark: #023047;
    --danger-color: #f44336;
    --success-color: #4caf50;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.portal-header {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: white;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.portal-header .logo .herb { font-size: 36px; }

.portal-header .stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
    opacity: 0.85;
}

.portal-header .stats span strong { font-size: 18px; display: block; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.portal-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

@media (max-width: 900px) {
    .portal-main { grid-template-columns: 1fr; }
    .portal-sidebar { order: -1; }
}

/* ============================================================
   SESSION CARD
   ============================================================ */
.session-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.session-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.session-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1a237e;
}

.session-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
}

.session-meta .badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-running { background: #e8f5e9; color: #2e7d32; }
.badge-completed { background: #e3f2fd; color: #1565c0; }
.badge-phase { background: #fff3e0; color: #e65100; }

/* ============================================================
   PROGRESS BAR (статус-бар для долгих операций)
   ============================================================ */
.progress-bar-wrap {
    margin: 16px 24px;
    padding: 12px 16px;
    background: #f0f4ff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar-wrap .progress-label {
    font-size: 13px;
    font-weight: 500;
    color: #1a237e;
    white-space: nowrap;
}

.progress-bar-wrap .progress-track {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-wrap .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a237e, #3949ab);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-bar-wrap .progress-pct {
    font-size: 12px;
    font-weight: 700;
    color: #1a237e;
    min-width: 36px;
    text-align: right;
}

/* ============================================================
   PHASE ACCORDION
   ============================================================ */
.phase-accordion {
    border-bottom: 1px solid var(--border);
}

.phase-accordion:last-child { border-bottom: none; }

.phase-header {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.phase-header:hover { background: #f5f6f8; }

.phase-header .phase-arrow {
    transition: transform var(--transition);
    font-size: 12px;
    color: var(--text-muted);
}

.phase-header.open .phase-arrow { transform: rotate(90deg); }

.phase-header .phase-icon { font-size: 20px; }
.phase-header .phase-title { font-weight: 600; flex: 1; }
.phase-header .phase-count {
    background: #f0f2f5;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.phase-header.current {
    background: #f0f4ff;
    border-left: 4px solid #1a237e;
}

.phase-header.current .phase-title { color: #1a237e; }

.phase-body {
    display: none;
    padding: 0 24px 16px;
}

.phase-body.open { display: block; }

/* ============================================================
   MESSAGE CARD
   ============================================================ */
.message-card {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    background: white;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
    animation: msgSlideIn 0.3s ease;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-card:hover { box-shadow: var(--shadow-sm); }

.message-card .msg-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    font-weight: 700;
    color: white;
}

.msg-avatar.admin { background: var(--color-admin); }
.msg-avatar.federal { background: var(--color-federal); }
.msg-avatar.shadow { background: var(--color-shadow); }
.msg-avatar.civil { background: var(--color-civil); }
.msg-avatar.moderator { background: var(--color-moderator); color: #333; }

.message-card .msg-content { flex: 1; min-width: 0; }

.msg-content .msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.msg-content .msg-agent {
    font-weight: 700;
    font-size: 14px;
}

.msg-content .msg-position {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.msg-position.support { background: #e8f5e9; color: #2e7d32; }
.msg-position.oppose { background: #ffebee; color: #c62828; }
.msg-position.neutral { background: #f5f5f5; color: #616161; }
.msg-position.propose_alternative { background: #e3f2fd; color: #1565c0; }

.msg-content .msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.msg-content .msg-text {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
}

.msg-content .msg-addressing {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.msg-content .msg-tone {
    display: inline-block;
    font-size: 14px;
    margin-left: 4px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.portal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-card {
    background: var(--card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.sidebar-card h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1a237e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Participant list */
.participant-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: background var(--transition);
}

.participant-item:hover { background: #f5f6f8; }

.participant-item .pi-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pi-dot.admin { background: var(--color-admin); }
.pi-dot.federal { background: var(--color-federal); }
.pi-dot.shadow { background: var(--color-shadow); }
.pi-dot.civil { background: var(--color-civil); }

.participant-item .pi-name { flex: 1; }
.participant-item .pi-vote {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
}

.pi-vote.support { background: #e8f5e9; color: #2e7d32; }
.pi-vote.oppose { background: #ffebee; color: #c62828; }
.pi-vote.neutral { background: #f5f5f5; color: #616161; }
.pi-vote.thinking { background: #fff3e0; color: #e65100; }

/* Vote summary */
.vote-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    text-align: center;
}

.vote-summary .vote-item {
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.vote-item.for { background: #e8f5e9; }
.vote-item.against { background: #ffebee; }
.vote-item.abstain { background: #f5f5f5; }

.vote-item .vote-count {
    font-size: 28px;
    font-weight: 800;
    display: block;
}

.vote-item.for .vote-count { color: #2e7d32; }
.vote-item.against .vote-count { color: #c62828; }
.vote-item.abstain .vote-count { color: #616161; }

/* Decision banner */
.decision-banner {
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 700;
    font-size: 16px;
}

.decision-banner.approved { background: #e8f5e9; color: #2e7d32; }
.decision-banner.rejected { background: #ffebee; color: #c62828; }
.decision-banner.deferred { background: #f5f5f5; color: #616161; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #1a237e;
    color: white;
}

.btn-primary:hover { background: #283593; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-success { background: #2e7d32; color: white; }
.btn-danger { background: #c62828; color: white; }
.btn-outline {
    background: transparent;
    border: 2px solid #1a237e;
    color: #1a237e;
}

/* ============================================================
   SESSION LIST (главная страница)
   ============================================================ */
.session-list {
    display: grid;
    gap: 16px;
}

.session-list-item {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 5px solid transparent;
}

.session-list-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.session-list-item.approved { border-left-color: #2e7d32; }
.session-list-item.rejected { border-left-color: #c62828; }
.session-list-item.running { border-left-color: #f9a825; }

.session-list-item h3 { font-size: 16px; margin-bottom: 6px; }
.session-list-item .sli-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex; gap: 12px;
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-avatar { width: 42px; height: 42px; border-radius: 50%; }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    gap: 10px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.toolbar .filter-chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    border: 2px solid var(--border);
    background: white;
    transition: all var(--transition);
}

.filter-chip.active { border-color: #1a237e; background: #f0f4ff; }
.filter-chip.all { border-color: #333; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    animation: toastSlideIn 0.3s ease;
    max-width: 350px;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.info { background: #1a237e; color: white; }
.toast.success { background: #2e7d32; color: white; }
.toast.warning { background: #e65100; color: white; }

/* ============================================================
   PROGRESS OVERLAY
   ============================================================ */
.progress-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000; animation: fadeIn 0.3s;
}
.progress-card {
    background: #fff; border-radius: 16px; padding: 30px 36px;
    min-width: 340px; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.progress-icon { font-size: 36px; margin-bottom: 10px; animation: pulse 1.5s infinite; }
.progress-title { font-size: 16px; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
.progress-subtitle { font-size: 13px; color: #888; margin-bottom: 16px; }
.progress-bar-container {
    width: 100%; height: 6px; background: #e0e0e0; border-radius: 3px;
    overflow: hidden; margin-bottom: 12px;
}
.progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, #2d6a9f, #4caf50);
    border-radius: 3px; transition: width 0.5s ease; width: 0%;
}
.progress-stats { display: flex; justify-content: space-between; font-size: 13px; color: #888; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ============================================================
   V3.0: ГЛОБАЛЬНЫЙ СТАТУС-БАР
   ============================================================ */
.global-status-bar {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99990;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 16px 24px;
    display: none;
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 280px;
    max-width: 400px;
    transition: opacity 0.3s ease;
    opacity: 0;
}
.global-status-bar.active {
    display: flex;
    opacity: 1;
}
.gsb-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #1a237e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gsb-text {
    font-size: 13px;
    color: #1a1a1a;
    font-weight: 500;
    line-height: 1.3;
    flex: 1;
}
.gsb-progress {
    width: 80px;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}
.gsb-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1a237e, #2d6a9f);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ======== ВЕЧЕРНЯЯ СВОДКА & ХРОНИКА ======== */
#digest-date, #timeline-date {
    max-width: 160px;
    cursor: pointer;
    transition: border-color 0.2s;
}
#digest-date:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 0 2px rgba(26,35,126,0.1);
}
#tab-evening h3 {
    color: #1a237e;
}
#evening-digest-content {
    max-height: 500px;
    overflow-y: auto;
}
.digest-section-title {
    font-weight: 700;
    font-size: 13px;
    color: #1a237e;
    margin-bottom: 8px;
}
.digest-metric-card {
    background: #fafafa;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    transition: transform 0.15s;
}
.digest-metric-card:hover {
    transform: translateY(-1px);
}
