/* TinyProgrammer Web UI Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

/* Navigation */
nav {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-links a {
    color: white;
    text-decoration: none;
    margin-left: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.1);
}

.nav-links a.active {
    background: rgba(255,255,255,0.2);
}

/* Main Content */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

h1 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

h2 {
    margin: 1.5rem 0 1rem;
    color: #34495e;
    font-size: 1.2rem;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Live display preview */
.preview-container {
    margin-bottom: 1.5rem;
    text-align: center;
}

.preview-stream {
    max-width: 100%;
    border: 2px solid #2c3e50;
    border-radius: 6px;
    background: #000;
    display: block;
    margin: 0 auto;
    image-rendering: pixelated;
}

/* Dashboard Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.status-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.status-card h3 {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.like-heart {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.4rem;
    color: #ccc;
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
}

.like-heart:hover {
    color: #e74c3c;
}

.like-heart.liked {
    color: #e74c3c;
}

.status-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

/* State colors */
.state-boot { color: #3498db; }
.state-think { color: #9b59b6; }
.state-write { color: #27ae60; }
.state-review { color: #f39c12; }
.state-run { color: #2ecc71; }
.state-watch { color: #1abc9c; }
.state-fix { color: #e74c3c; }
.state-archive { color: #34495e; }
.state-reflect { color: #8e44ad; }
.state-error { color: #c0392b; }

/* Type Stats */
.type-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.type-stat {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.type-name {
    color: #666;
}

.type-count {
    font-weight: bold;
    margin-left: 0.5rem;
}

.refresh-hint {
    color: #666;
    font-size: 0.9rem;
    margin-top: 2rem;
}

/* Forms */
.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Ollama detection status */
.ollama-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.ollama-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ollama-indicator.ollama-checking {
    background: #f39c12;
}

.ollama-indicator.ollama-on {
    background: #27ae60;
}

.ollama-indicator.ollama-off {
    background: #bdc3c7;
}

.default-hint {
    display: block;
    color: #999;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.description-input {
    font-family: inherit;
    resize: vertical;
}

/* Program Types Grid */
.program-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.program-type-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.program-type-item label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.weight-input {
    width: 60px !important;
}

/* Program type section heading + master toggle */
.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.section-heading h2 {
    margin: 1.5rem 0 0.25rem;
}

.master-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: #34495e;
    cursor: pointer;
    user-select: none;
}

/* Program type editor rows */
.type-row {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #bdc3c7;
}

.type-row.custom {
    border-left-color: #2980b9;
}

.type-row-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.type-row-header label {
    cursor: pointer;
    font-weight: 600;
}

.type-row-header .slug {
    color: #7f8c8d;
    font-size: 0.85rem;
    font-family: monospace;
}

.type-row .desc-row {
    display: block;
    width: 100%;
}

.type-row textarea {
    width: 100%;
    box-sizing: border-box;
}

.type-row-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.type-row-meta select {
    padding: 0.25rem;
}

.btn-delete {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-delete:hover {
    background: #c0392b;
}

.add-custom-type {
    padding: 1rem;
    background: #ecf0f1;
    border-radius: 4px;
    margin-top: 1rem;
}

.add-custom-type .form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.add-custom-type .form-row > div {
    flex: 1;
    min-width: 120px;
}

/* Session history table */
.session-history-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ecf0f1;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.session-history {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.session-history th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid #2c3e50;
    font-weight: 600;
}

.session-history td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #ecf0f1;
}

.session-history tr.failure td {
    color: #c0392b;
}

.mode-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
}

.mode-core { background: #d5f5e3; color: #1e8449; }
.mode-creative { background: #ebdef0; color: #7d3c98; }
.mode-variation { background: #fdebd0; color: #ca6f1e; }

/* Buttons */
.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #3498db;
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #ecf0f1;
    color: #333;
    border: 1px solid #bdc3c7;
}

.btn-secondary:hover {
    background: #bdc3c7;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

footer a {
    color: #3498db;
}

/* Responsive */
@media (max-width: 600px) {
    nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links a {
        margin-left: 0.5rem;
    }

    main {
        padding: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* Info bubble (used in dashboard schedule tile) */
.info-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 0.4rem;
    border-radius: 50%;
    background: #888;
    color: #fff;
    font-size: 0.7rem;
    font-style: italic;
    font-weight: bold;
    font-family: serif;
    cursor: help;
    position: relative;
    vertical-align: middle;
    user-select: none;
}

.info-bubble .info-tooltip {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s;
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    background: #222;
    color: #eee;
    padding: 0.6rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-style: normal;
    font-weight: normal;
    font-family: inherit;
    line-height: 1.4;
    text-align: left;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.info-bubble .info-tooltip code {
    background: #444;
    padding: 0.05rem 0.25rem;
    border-radius: 2px;
    font-size: 0.75rem;
}

.info-bubble:hover .info-tooltip,
.info-bubble:focus .info-tooltip {
    visibility: visible;
    opacity: 1;
}
