/* MSP Cost Estimator - Styles */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.navbar {
    background: var(--text);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
}

.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: #cbd5e1; text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: white; }

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user-name {
    color: #cbd5e1;
    font-size: 0.85rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid #64748b;
    color: #cbd5e1;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

.btn-logout:hover {
    background: #475569;
    color: white;
    border-color: #94a3b8;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

.page-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .page-grid { grid-template-columns: 1fr; }
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
}

legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 0.5rem;
    color: var(--primary);
}

.form-group {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label {
    flex: 0 0 55%;
    font-size: 0.875rem;
}

.form-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    width: 100%;
}

.form-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.checkbox-group { flex-direction: row-reverse; justify-content: flex-end; }
.checkbox-group label { flex: unset; }
.form-checkbox { width: 1.1rem; height: 1.1rem; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }

.htmx-indicator { display: none; color: var(--text-muted); font-size: 0.85rem; }
.htmx-request .htmx-indicator { display: inline; }

.result-column {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.result-highlight {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-big {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0.25rem;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.result-table th,
.result-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.result-table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.result-table details summary {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.8rem;
}

.result-table pre {
    font-size: 0.75rem;
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 0.25rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert a { color: inherit; font-weight: 600; }

.detail-meta { margin-bottom: 1.5rem; }
.detail-meta p { margin-bottom: 0.25rem; }

.params-list { margin-bottom: 1rem; }
.params-list dt { font-weight: 600; float: left; clear: left; width: 45%; font-size: 0.9rem; }
.params-list dd { margin-left: 50%; font-size: 0.9rem; margin-bottom: 0.25rem; }

.error { color: var(--danger); font-size: 0.8rem; }

/* ---- Hours Override Editor ---- */

.hours-editor-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--card-bg);
}

.hours-editor-section > summary {
    cursor: pointer;
    user-select: none;
}

.hours-editor-section > summary:hover {
    color: var(--primary);
}

.hours-table .hours-input {
    width: 5.5rem;
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
    text-align: right;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.hours-table .hours-input:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}

.hours-table .hours-month-display {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: right;
}

/* Overridden row / input highlighting */
.row-overridden {
    background: #fffbeb;
}

.input-overridden {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
    font-weight: 600;
}

.alert-override {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

/* ---- Info Tooltip ---- */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: default;
    position: relative;
    vertical-align: middle;
    margin-left: 0.3rem;
    flex-shrink: 0;
}

.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    transform: none;
    background: #1e293b;
    color: white;
    font-size: 0.75rem;
    font-weight: 400;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    width: max-content;
    max-width: 260px;
    white-space: normal;
    line-height: 1.4;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.info-icon:hover::after {
    opacity: 1;
}

/* ---- Login Page ---- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 8rem);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    text-align: center;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.login-field .form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}

.login-btn {
    width: 100%;
    padding: 0.6rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* ---- Fieldset collassabili ---- */
.fieldset-collapsible {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: var(--card-bg);
}

.fieldset-collapsible > summary {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    cursor: pointer;
    user-select: none;
    list-style: revert;
}

.fieldset-collapsible > summary:hover {
    color: var(--primary-hover);
}

.fieldset-collapsible > fieldset {
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 0;
}
