/* ==========================================
   Unified Widget Styles
   ========================================== */

/* --- Widget Title Area --- */

.widget-title-area {
    margin-bottom: 20px;
}

.widget-title-line {
    width: 60px;
    height: 2px;
    background: #41ffd2;
    margin-bottom: 10px;
}

.widget-title {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #41ffd2;
    margin: 0;
}

/* --- Summary Two-Column Layout --- */

.widget-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 40px;
}

.widget-summary-column {
    display: flex;
    flex-direction: column;
}

.widget-summary-column + .widget-summary-column {
    border-left: 0.5px solid rgba(65, 255, 210, 0.15);
    padding-left: 40px;
}

/* --- Category Headers --- */

.widget-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 12px;
}

.widget-category-header:first-child {
    margin-top: 0;
}

.widget-category-name {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 3px 8px;
    display: inline-block;
}

.widget-category-name.komun {
    color: #000;
    background: #19FF00;
}

.widget-category-name.even {
    color: #fff;
    background: #8068E9;
}

.widget-category-name.decyz {
    color: #fff;
    background: #007AFF;
}

.widget-category-name.bran {
    color: #000;
    background: #FFA300;
}

.widget-category-count {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #41ffd2;
}

/* --- Category Divider --- */

.widget-category-divider {
    width: 100%;
    height: 0.5px;
    background: rgba(65, 255, 210, 0.2);
    margin: 20px 0;
}

/* --- Metric Items (Summary) --- */

.widget-metric-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.widget-metric-icon {
    flex-shrink: 0;
    margin-top: 3px;
}

.widget-metric-icon svg {
    width: 14px;
    height: 14px;
}

.widget-metric-text {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    color: #41ffd2;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.widget-metric-text .metric-headline {
    font-weight: 600;
}

.widget-metric-text .metric-desc {
    font-weight: 400;
    opacity: 0.65;
    margin-top: 2px;
    font-size: 10px;
}

/* --- Metrics List View --- */

.widget-metrics-list-view {
    width: 100%;
}

.widget-metrics-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 30px;
}

.widget-metrics-col {
    display: flex;
    flex-direction: column;
}

.widget-metrics-col + .widget-metrics-col {
    border-left: 0.5px solid rgba(65, 255, 210, 0.15);
    padding-left: 30px;
}

.widget-metric-selectable {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1px solid transparent;
}

.widget-metric-selectable:hover {
    background: rgba(65, 255, 210, 0.08);
    border-color: rgba(65, 255, 210, 0.2);
}

.widget-metric-selectable.selected {
    background: rgba(65, 255, 210, 0.15);
    border-color: rgba(65, 255, 210, 0.4);
}

.widget-metric-shape {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.widget-metric-shape.circle {
    border-radius: 50%;
}

.widget-metric-shape.diamond {
    transform: rotate(45deg);
    width: 8px;
    height: 8px;
}

.widget-metric-shape.komun { background: #19FF00; }
.widget-metric-shape.even { background: #8068E9; }
.widget-metric-shape.decyz { background: #007AFF; }
.widget-metric-shape.bran { background: #FFA300; }

.widget-metric-label {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    color: #41ffd2;
    font-weight: 400;
    line-height: 1.4;
}

/* --- Metrics Footer --- */

.widget-metrics-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 0.5px solid rgba(65, 255, 210, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-metrics-count {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    color: rgba(65, 255, 210, 0.6);
}

.widget-metrics-count strong {
    color: #41ffd2;
}

.widget-generate-btn {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #41ffd2;
    background: rgba(65, 255, 210, 0.35);
    border: 0px;
    border-radius: 0px !important;
    padding: 8px 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.widget-generate-btn span {
    position: relative;
    z-index: 2;
}

.widget-generate-btn::after {
    position: absolute;
    content: "";
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: #41ffd2;
    transition: all 0.35s ease;
    z-index: 1;
}

.widget-generate-btn:hover::after {
    width: 100%;
}

.widget-generate-btn:hover {
    color: #000;
}

/* --- Action Buttons inside widget --- */

.widget-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 0.5px solid rgba(65, 255, 210, 0.2);
    display: flex;
    gap: 10px;
}

.widget-action-btn {
    flex: 1;
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #41ffd2;
    background: rgba(65, 255, 210, 0.35);
    border: 0px;
    border-radius: 0px !important;
    padding: 10px 16px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.widget-action-btn span {
    position: relative;
    z-index: 2;
}

.widget-action-btn::after {
    position: absolute;
    content: "";
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: #41ffd2;
    transition: all 0.35s ease;
    z-index: 1;
}

.widget-action-btn:hover::after {
    width: 100%;
}

.widget-action-btn:hover {
    color: #000;
}

/* --- Tooltip --- */

.metric-tooltip {
    position: fixed;
    background: rgba(10, 14, 18, 0.95);
    border: 0.5px solid rgba(65, 255, 210, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #41ffd2;
    padding: 10px 12px;
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 11px;
    max-width: 250px;
    z-index: 10005;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.metric-tooltip.visible {
    opacity: 1;
}

.metric-tooltip-content {
    line-height: 1.5;
}

/* --- Terminal Typing Animation --- */

.typing-target {
    display: block;
    min-height: 1em;
}

.typing-cursor {
    display: inline-block;
    width: 7px;
    height: 13px;
    background: #41ffd2;
    animation: cursorBlink 0.6s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 1px;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Welcome Screen (CodePen terminal style) --- */

.widget-welcome {
    font-family: 'Geist Mono', 'JetBrains Mono', 'SF Mono', monospace;
    color: #41ffd2;
    text-shadow: 0 0 3px rgba(65, 255, 210, 0.6);
    position: relative;
}

.welcome-logo {
    display: block;
    height: 50px;
    width: auto;
    margin-bottom: 20px;
    opacity: 0.85;
}

.widget-welcome pre {
    margin: 0;
    font-family: inherit;
    font-size: 10px;
    line-height: 1.15;
    color: #41ffd2;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    white-space: pre-wrap;
    overflow: hidden;
}

#welcomeInstructions {
    font-size: 13px;
    line-height: 1.5;
    margin-top: 16px;
    white-space: pre-wrap;
}

#welcomePrompt {
    font-size: 14px;
    margin-top: 12px;
    color: #41ffd2;
}

#welcomeInput {
    color: #41ffd2;
}

#welcomeOutput {
    font-size: 13px;
    line-height: 1.5;
    margin-top: 8px;
    white-space: pre-wrap;
}

#welcomeOutput strong {
    color: #fff;
}

/* Blinking cursor from CodePen */
@keyframes terminalBlink {
    0% { opacity: 0; }
    30% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

.terminal-blink {
    animation: terminalBlink 0.4s linear infinite;
    color: #41ffd2;
    text-shadow: 0 0 5px rgba(65, 255, 210, 0.8);
}

/* Interlaced scanlines (from CodePen) */
.welcome-interlaced {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        transparent 0px 1px,
        rgba(0, 0, 0, 0.15) 3px 4px
    );
    animation: scanlines 0.06666s linear infinite;
}

@keyframes scanlines {
    0% { background-position: 0px 0px; }
    50% { background-position: 0px 0px; }
    51% { background-position: 0px 2px; }
    100% { background-position: 0px 2px; }
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .widget-summary-grid,
    .widget-metrics-columns {
        grid-template-columns: 1fr;
    }

    .widget-summary-column + .widget-summary-column,
    .widget-metrics-col + .widget-metrics-col {
        border-left: none;
        padding-left: 0;
        border-top: 0.5px solid rgba(65, 255, 210, 0.15);
        padding-top: 20px;
        margin-top: 10px;
    }

    #unifiedWidget {
        width: 95%;
    }

    .widget-content {
        padding: 20px;
    }
}
