/* Universal Demo Styling
 * Shared across all Paxos demos (partial-roles, basic-protocol, preliminary-protocol, etc)
 * Individual demos can override these styles as needed
 */

/* ========== DEMO CONTAINER & LAYOUT ========== */
.demo-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

/* ========== VISUALIZATION ========== */
.visualization,
.visualization-main {
    position: relative;
    background: #0f172a;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #1e293b;
    min-height: 500px;
}

.viz-svg-container {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.viz-svg-container svg,
#partialRolesSvg,
#basicProtocolSvg,
#demovSvg {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* ========== PANELS & SIDEBARS ========== */
.topology-info-panel,
.floating-decree-viewer {
    background: #1e293b;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #334155;
    color: #e2e8f0;
}

.topology-info-panel h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#topologyDetails {
    font-size: 13px;
    line-height: 1.6;
}

/* ========== BUTTONS & TOGGLES ========== */
.btn-primary,
.btn-secondary,
.btn-compact {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #64748b;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

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

.btn-compact {
    flex: 1;
    font-size: 11px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 6px 12px;
}

.btn-compact:hover {
    background: #1e293b;
    border-color: #475569;
}

.btn-compact.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.layout-toggle {
    margin-top: 20px;
    display: flex;
    gap: 5px;
}

.layout-toggle .btn-compact {
    flex: 1;
}

/* ========== ROLE TAGS & LEGENDS ========== */
.role-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    margin-right: 4px;
    color: white;
}

.role-p {
    background: #60a5fa;
}

.role-a {
    background: #f59e0b;
}

.role-l {
    background: #10b981;
}

.role-legend {
    margin-top: 15px;
    padding: 10px;
    background: #0f172a;
    border-radius: 6px;
    border: 1px solid #334155;
}

.legend-title {
    font-size: 12px;
    font-weight: bold;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #cbd5e1;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #1e293b;
}

/* ========== STATS & EVENTS ========== */
.stats-and-logs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.scroll-log {
    height: 200px;
    overflow-y: auto;
    background: #0f172a;
    padding: 10px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #cbd5e1;
    border: 1px solid #334155;
}

.proposal-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.proposal-stat-item {
    padding: 6px 8px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    font-size: 12px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
}

.proposal-stat-item:hover {
    background: #1e293b;
    border-color: #475569;
}

.proposal-stat-item.selected {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.proposal-stat-item .node-id {
    font-weight: bold;
    color: #60a5fa;
}

.proposal-stat-item.selected .node-id {
    color: white;
}

/* ========== DECREE DISPLAY ========== */
.decree-hint {
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    padding: 20px 10px;
}

.decree-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.decree-node-label {
    font-size: 12px;
    font-weight: bold;
    color: #60a5fa;
    padding: 6px;
    background: #0f172a;
    border-radius: 4px;
}

.decree-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.decree-item {
    padding: 6px;
    background: #0f172a;
    border-left: 2px solid #34d399;
    border-radius: 3px;
}

.decree-text {
    font-size: 12px;
    color: #cbd5e1;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-word;
}

/* ========== CONTROL SECTIONS ========== */
.controls-section {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 20px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.partial-roles-demo .control-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 16px;
}

.partial-roles-demo .button-group {
    grid-column: 1 / -1;
}

.control-group h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.speed-control {
    display: flex;
    gap: 8px;
    align-items: center;
}

.speed-control input[type="range"] {
    flex: 1;
}

.speed-control span {
    color: #94a3b8;
    min-width: 40px;
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button-group button {
    flex: 1;
    min-width: 80px;
}

.partial-roles-demo .button-group {
    flex-direction: column;
    gap: 10px;
}

.partial-roles-demo .button-group .primary-controls,
.partial-roles-demo .button-group .step-controls {
    display: flex;
    gap: 8px;
}

.partial-roles-demo .button-group .primary-controls button,
.partial-roles-demo .button-group .step-controls button {
    flex: 1;
    min-width: 0;
}

.status-info {
    padding: 12px;
    background: #1e293b;
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
}

#statusTitle {
    font-weight: bold;
    color: #3b82f6;
    margin-bottom: 4px;
    font-size: 14px;
}

#statusDescription {
    font-size: 12px;
    color: #94a3b8;
}

/* ========== STATS ========== */
.stats-section {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 20px;
}

.stats-section h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
}

.stat-card {
    background: #1e293b;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #334155;
}

.stat-value {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.2;
}

/* ========== EVENT LOG ========== */
.event-log-section {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-log-section h3 {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.partial-roles-demo .event-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.partial-roles-demo .event-log-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.partial-roles-demo .event-filter-status {
    font-size: 11px;
    color: #94a3b8;
}

.partial-roles-demo .event-filter-toggle {
    border: 1px solid #334155;
    background: #111827;
    color: #cbd5e1;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.partial-roles-demo .event-filter-toggle:hover {
    border-color: #3b82f6;
    color: #e2e8f0;
}

.partial-roles-demo .event-log-wrapper {
    border: 1px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
    background: #0b1220;
}

.partial-roles-demo .event-filter-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(10, 18, 32, 0.95);
    border-bottom: 1px solid #1e293b;
    flex-wrap: wrap;
}

.partial-roles-demo .event-filter-bar.hidden {
    display: none;
}

.partial-roles-demo .event-filter-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

.partial-roles-demo .event-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.partial-roles-demo .event-filter-chip {
    border: 1px solid #334155;
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.partial-roles-demo .event-filter-chip .count {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 10px;
}

.partial-roles-demo .event-filter-chip.active {
    border-color: #3b82f6;
    color: #e2e8f0;
    background: rgba(59, 130, 246, 0.12);
}

.partial-roles-demo .event-filter-close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
}

.partial-roles-demo #eventLog {
    height: 200px;
    overflow-y: auto;
    padding: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #cbd5e1;
}

.partial-roles-demo .event-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    margin: 2px 0;
    background: #111827;
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    font-size: 11px;
    color: #cbd5e1;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-word;
    transition: opacity 0.2s ease, filter 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.partial-roles-demo .event-item.future {
    opacity: 0.35;
    filter: grayscale(80%);
}

.partial-roles-demo .event-item.filtered {
    display: none;
}

.partial-roles-demo .event-time {
    font-size: 10px;
    color: #94a3b8;
    min-width: 60px;
    text-align: right;
    white-space: nowrap;
}

.partial-roles-demo .event-text {
    flex: 1;
}

.partial-roles-demo .playback-cursor {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
}

/* ========== FORMS & INPUTS ========== */
select {
    pointer-events: auto;
    cursor: pointer;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%;
}

select:hover {
    border-color: #475569;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
}

input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}

/* ========== DESCRIPTIONS & TEXT ========== */
.scenario-description {
    font-size: 13px;
    line-height: 1.5;
    color: #cbd5e1;
}

.scenario-description p {
    margin: 0;
    padding: 4px 0;
}

.scenario-description p:first-child {
    color: #94a3b8;
    font-size: 12px;
}

.scenario-description p:last-child {
    color: #60a5fa;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .visualization-main {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 768px) {
    .demo-container {
        padding: 12px;
        gap: 12px;
    }

    .visualization,
    .visualization-main {
        min-height: 350px;
        padding: 10px;
    }

    .scroll-log {
        height: 150px;
    }

    .partial-roles-demo .controls-section {
        padding: 14px;
    }

    .partial-roles-demo .event-log-section {
        padding: 12px;
        gap: 10px;
    }

    .partial-roles-demo #eventLog {
        height: 160px;
    }

    .partial-roles-demo .event-filter-bar {
        gap: 6px;
        padding: 6px;
    }

    .partial-roles-demo .event-filter-chip {
        padding: 3px 6px;
        font-size: 9px;
    }
}

@media (max-width: 900px) {
    .partial-roles-demo .control-grid {
        grid-template-columns: 1fr;
    }

    .partial-roles-demo .button-group {
        grid-column: auto;
    }
}

@media (max-width: 520px) {
    .partial-roles-demo .button-group .primary-controls,
    .partial-roles-demo .button-group .step-controls {
        flex-direction: column;
    }

    .partial-roles-demo .event-filter-chip .count {
        display: none;
    }

    .partial-roles-demo .event-time {
        min-width: 48px;
    }
}
