/**
 * Sistemi Personali - Page-specific styles.
 *
 * Uses existing theme classes from internal.css where possible.
 */

/* ── Algorithm card list ── */
.algo-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.algo-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    transition: border-color 0.15s;
}

.algo-card:hover {
    border-color: var(--blue-accent);
}

.algo-card.default {
    border-left: 4px solid var(--gray-400);
    background: var(--gray-50);
}

.algo-card-info {
    flex: 1;
    min-width: 0;
}

.algo-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.algo-card-name .lock-icon {
    color: var(--gray-400);
    font-size: 0.9rem;
}

.algo-card-desc {
    font-size: 1rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.algo-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.algo-card-actions button {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    transition: background 0.15s;
}

.algo-card-actions button:hover {
    background: var(--gray-100);
}

.algo-card-actions .btn-run {
    background: var(--green);
    color: var(--white);
    border-color: var(--green);
}

.algo-card-actions .btn-run:hover {
    background: var(--green-accent);
}

.algo-card-actions .btn-delete {
    color: var(--red);
    border-color: var(--red);
}

.algo-card-actions .btn-delete:hover {
    background: #fef2f2;
}

/* ── Editor area ── */
.algo-editor-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.algo-editor-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.algo-editor-header input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 1rem;
}

.algo-editor-header input:focus {
    outline: none;
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.2);
}

.algo-editor-textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: #1e1e2e;
    color: #cdd6f4;
    resize: vertical;
    tab-size: 4;
}

.algo-editor-textarea:focus {
    outline: none;
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.2);
}

.algo-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.algo-editor-toolbar .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    transition: background 0.15s;
}

.algo-editor-toolbar .btn:hover {
    background: var(--gray-100);
}

.algo-editor-toolbar .btn-run {
    background: var(--green);
    color: var(--white);
    border-color: var(--green);
}

.algo-editor-toolbar .btn-run:hover {
    background: var(--green-accent);
}

.algo-editor-toolbar .btn-stop {
    background: var(--red);
    color: var(--white);
    border-color: var(--red);
}

/* ── Budget indicator ── */
.algo-budget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--gray-600);
    margin-left: auto;
}

.algo-budget-bar {
    width: 120px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.algo-budget-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width 0.3s;
}

.algo-budget-fill.warning {
    background: var(--accent);
}

.algo-budget-fill.danger {
    background: var(--red);
}

/* ── Output area ── */
.algo-output {
    min-height: 150px;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.algo-output .log-line {
    padding: 0.1rem 0;
}

.algo-output .log-error {
    color: var(--red);
}

.algo-output .log-info {
    color: var(--blue-accent);
}

.algo-output-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.algo-output-table th {
    background: var(--gray-100);
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--gray-200);
}

.algo-output-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* ── Empty state ── */
.algo-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
    font-size: 1.1rem;
}

/* ── Guide content ── */
.algo-guide {
    line-height: 1.7;
}

.algo-guide h2 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--gray-800);
}

.algo-guide h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
}

.algo-guide ul,
.algo-guide ol {
    padding-left: 2rem;
    margin: 0.5rem 0 1rem;
}

.algo-guide li {
    margin-bottom: 0.35rem;
}

.algo-guide hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--gray-200);
}

.algo-guide code {
    background: var(--gray-100);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: 'Courier New', Courier, monospace;
}

.algo-guide pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0.75rem 0;
}

/* ── Privacy banner ── */
.algo-privacy {
    background: var(--gray-100);
    border-left: 4px solid var(--green);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    border-radius: 0 6px 6px 0;
}

.algo-privacy strong {
    color: var(--green);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .algo-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .algo-card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .algo-editor-textarea {
        min-height: 200px;
    }

    .algo-budget {
        width: 100%;
        margin-left: 0;
    }

    .algo-editor-toolbar {
        flex-direction: column;
    }

    .algo-editor-toolbar .btn {
        width: 100%;
        justify-content: center;
    }
}
