/* Aspectul aplicației desktop (tema light), preluat din App.xaml. */
:root {
    --bg: #F5F7FB;
    --surface: #FFFFFF;
    --sidebar: #111827;
    --sidebar-text: #D1D5DB;
    --sidebar-muted: #9CA3AF;
    --sidebar-divider: #263244;
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --text: #111827;
    --muted: #6B7280;
    --border: #E5E7EB;
    --success: #16A34A;
    --danger: #DC2626;
    --control-surface: #FFFFFF;
    --control-border: #D1D5DB;
    --secondary-btn: #EEF2FF;
    --secondary-btn-text: #1E40AF;
    --secondary-btn-border: #DBEAFE;
    --cal-cell: #FFFFFF;
    --cal-weekend: #F8FAFC;
    --cal-weekend-border: #93C5FD;
    --cal-unassigned: #FFF7F7;
    --cal-unassigned-border: #FCA5A5;
    --cal-assigned: #F0FDF4;
    --cal-hover: #EFF6FF;
    --cal-badge: #F1F5F9;
    --cal-badge-text: #64748B;
    --cal-status-text: #64748B;
    --cal-doctor: #EFF6FF;
    --cal-doctor-text: #1E3A8A;
    --cal-unassigned-text: #B91C1C;
    --cal-weekday-header: #0F766E;
    --cal-weekend-header: #1E3A8A;
    --status-surface: #ECFDF5;
    --status-text: #166534;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
    font-size: 12px;
}

h1 { margin: 0; font-size: 28px; font-weight: 600; }
h1:focus { outline: none; }
button { font-family: inherit; }
ul.plain-list { list-style: none; margin: 0; padding: 0; }

.muted { color: var(--muted); }
.muted11 { color: var(--muted); font-size: 11px; }
.muted12 { color: var(--muted); font-size: 12px; }
.h14 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.h17 { font-size: 17px; font-weight: 600; }
.h20 { font-size: 20px; font-weight: 600; }
.spaced-3 { margin-top: 3px; }
.spaced-4 { margin-top: 4px; }
.bottom-10 { margin-bottom: 10px; }
.bottom-18 { margin-bottom: 18px; }
.top-22 { margin-top: 22px; }

/* ---------- Carduri ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.card-label { font-size: 10px; font-weight: 700; color: var(--muted); }

/* ---------- Butoane ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 7px;
    padding: 10px 18px;
    margin: 0 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { background: var(--primary); }
.btn.secondary {
    background: var(--secondary-btn);
    color: var(--secondary-btn-text);
    border: 1px solid var(--secondary-btn-border);
}
.btn.secondary:hover { background: var(--secondary-btn); filter: none; }
.btn.no-margin { margin: 0; }
.file-input { display: none; }

/* ---------- Câmpuri ---------- */
.field-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }

select.field {
    appearance: none;
    height: 38px;
    min-width: 125px;
    padding: 0 34px 0 8px;
    border: 1px solid var(--control-border);
    border-radius: 8px;
    background: var(--control-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2364748B' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}
select.field:focus, .text-field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
select.field:disabled { opacity: .55; }
select.field.year { width: 105px; }

.text-field {
    height: 38px;
    width: 100%;
    padding: 0 9px;
    border: 1px solid var(--control-border);
    border-radius: 8px;
    background: var(--control-surface);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}
.text-field.compact { height: 32px; padding: 0 7px; }

/* ---------- Structura paginii ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--sidebar);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; }
.logo-box {
    width: 36px; height: 36px; border-radius: 9px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo-box img { width: 24px; height: 24px; object-fit: contain; }
.brand > div:last-child { margin-left: 10px; }
.brand-name { color: #fff; font-size: 21px; font-weight: 700; line-height: 1.2; }
.brand-sub { color: var(--sidebar-muted); font-size: 11px; }

.sidebar-divider { height: 1px; background: var(--sidebar-divider); margin: 0 0 15px; }
.sidebar-divider.top { margin: 24px 0 18px; }
.sidebar-label { color: var(--sidebar-muted); font-size: 10px; font-weight: 700; margin: 0 0 7px 5px; }
.sidebar-label.spaced { margin-top: 25px; }

.sidebar-btn {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--sidebar-text);
    border: 0;
    border-radius: 7px;
    padding: 11px 14px;
    margin: 2px 0;
    font-size: 13px;
    cursor: pointer;
}
.sidebar-btn:hover { background: var(--sidebar-divider); color: #fff; }
.sidebar-btn.active { background: var(--primary); color: #fff; }

.sidebar-bottom { margin-top: auto; }
.sidebar-foot { color: var(--sidebar-muted); font-size: 11px; }
.sidebar-foot.small { font-size: 10px; margin-top: 3px; }
.sidebar-foot.spaced { margin-top: 8px; }

.content { padding: 24px 28px 20px; min-width: 0; display: flex; flex-direction: column; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status-pill {
    display: flex; align-items: center;
    background: var(--status-surface); color: var(--status-text);
    border-radius: 15px; padding: 6px 11px;
    font-size: 12px; font-weight: 600;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 7px; }

.controls { display: flex; align-items: flex-end; padding: 18px; margin-bottom: 16px; }
.control-group.year { margin-left: 12px; }
.controls-divider { width: 1px; align-self: stretch; background: var(--border); margin: 4px 20px; }
.control-actions { display: flex; align-items: flex-end; }
.controls-spacer { flex: 1; }

.summary-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.summary-card { padding: 16px; }
.card-value { font-size: 25px; font-weight: 600; margin-top: 4px; }
.card-value.small { font-size: 16px; margin-top: 8px; }
.card-sub { font-size: 11px; color: var(--muted); }

.workspace { padding: 0; flex: 1; min-height: 0; }

.statusbar { display: flex; justify-content: space-between; align-items: center; margin: 12px 2px 0; }
.status-text { color: var(--muted); font-size: 11px; }
.status-brand { color: var(--sidebar-muted); font-size: 10px; }

/* ---------- Tab-uri ---------- */
.tabs { display: flex; padding: 0 12px; }
.tab {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 7px 7px 0 0;
    padding: 8px 14px;
    margin-right: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.tab:hover { background: var(--cal-weekend); color: var(--text); }
.tab.active { background: var(--surface); border-color: var(--border); color: var(--text); }
.tab-body { padding: 0 12px; }

.panel-pad { padding: 12px; }
.panel-pad.large { padding: 22px; }

/* ---------- Calendar ---------- */
.calendar-panel { margin-top: 12px; }
.calendar-title { display: flex; justify-content: space-between; align-items: center; margin: 0 8px 10px; }
.calendar-hint { margin-left: 10px; }
.mobile-hint { display: none; }

.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekday-row { margin: 0 4px 4px; }
.weekday {
    background: var(--cal-weekday-header); color: #fff;
    font-size: 11px; font-weight: 700; text-align: center;
    padding: 7px 0;
}
.weekday.weekend { background: var(--cal-weekend-header); }
.calendar-grid { margin: 0 4px 8px; }

.day-cell {
    display: flex; flex-direction: column; justify-content: space-between;
    text-align: left;
    margin: 3px; padding: 10px; min-height: 112px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--cal-cell);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}
/* În aplicația desktop celulele sunt albe cu bordură gri: culorile de stare din XAML nu se aplică efectiv. */
.day-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.day-cell.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.day-top { display: flex; justify-content: space-between; align-items: flex-start; }
.day-number { font-size: 20px; font-weight: 700; line-height: 1.25; }
.day-badge {
    background: var(--cal-badge); color: var(--cal-badge-text);
    border-radius: 10px; padding: 4px 8px;
    font-size: 9px; font-weight: 600;
}
.day-middle { display: flex; flex-direction: column; margin: 8px 0 6px; }
.day-caption { font-size: 9px; font-weight: 700; color: var(--muted); }
.doctor-box {
    background: var(--cal-doctor); color: var(--cal-doctor-text);
    border-radius: 7px; padding: 6px 8px; margin-top: 3px;
    font-size: 14px; font-weight: 700;
}
.doctor-box.unassigned { color: var(--cal-unassigned-text); }
.status-badge {
    align-self: flex-start;
    display: inline-flex; align-items: center;
    background: var(--cal-badge); color: var(--cal-status-text);
    border-radius: 9px; padding: 3px 7px;
    font-size: 10px; font-weight: 600;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.status-dot.ok { background: var(--success); }
.status-dot.bad { background: var(--danger); }

.day-editor { display: grid; grid-template-columns: 220px 1fr; margin: 0 8px 8px; padding: 14px; }
.selected-date { font-size: 20px; font-weight: 600; margin-top: 4px; }
.assign-row { display: flex; align-items: center; margin: 6px 0 2px; }
.assign-select { width: 220px; }
.assign-btn { padding: 8px 14px; margin: 0 0 0 8px; }
.availability-list { margin-top: 5px; max-height: 76px; overflow-y: auto; }
.availability-list li { display: flex; align-items: center; margin: 2px 0; font-size: 12px; }
.avail-dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; flex-shrink: 0; }

/* ---------- Tabele și liste ---------- */
.grid-table { border-collapse: collapse; table-layout: fixed; }
.grid-table th {
    background: var(--cal-weekend); color: var(--text);
    text-align: left; font-weight: 400;
    padding: 7px 10px;
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.grid-table td { padding: 6px 10px; }
.grid-table tbody tr:hover { background: var(--cal-weekend); }
.summary-table { margin-top: 12px; }

.validation-list { margin-top: 12px; font-size: 13px; }
.validation-list.large { font-size: 14px; }
.validation-list li { padding: 3px 0; }

.history-list li { display: flex; margin: 6px 0; }
.history-time { width: 170px; flex-shrink: 0; }
.history-message { font-weight: 600; }
.history-user { margin-left: 12px; }

.history-tabs { padding: 0; margin: 14px 0 12px; border-bottom: 1px solid var(--border); }
.audit-filters { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.audit-list li { flex-wrap: wrap; align-items: baseline; padding: 7px 0; margin: 0; border-bottom: 1px solid var(--border); }
.audit-list .history-time { width: 130px; }
.audit-action {
    width: 150px; flex-shrink: 0;
    font-size: 11px; font-weight: 600; color: var(--cal-badge-text);
}
.audit-action.bad { color: var(--cal-unassigned-text); }
.audit-details { width: 100%; margin-top: 4px; padding-left: 130px; color: var(--muted); }
.audit-details summary { cursor: pointer; font-size: 11px; }
.audit-details pre {
    margin: 6px 0 2px; padding: 10px; max-height: 260px; overflow: auto;
    background: var(--cal-weekend); border-radius: 7px;
    font-size: 11px; color: var(--text); white-space: pre-wrap; word-break: break-word;
}

/* ---------- Reguli ---------- */
.rule-grid { display: grid; grid-template-columns: 260px 150px 260px 150px; align-items: center; margin-bottom: 16px; }
.rule-grid.single { grid-template-columns: 260px 150px; }
.rule-grid .second { margin-left: 28px; }
.rule-grid input.second { margin-left: 12px; width: calc(100% - 12px); }
.rule-grid .second { grid-column: 3; }
.rule-grid input.second { grid-column: 4; }

.check { display: block; margin: 5px 0; cursor: pointer; }
.check input { margin-right: 4px; }

.override-list { max-height: 230px; overflow: auto; }
.override-row {
    display: grid;
    grid-template-columns: 190px 95px 95px 95px 205px 205px 215px 95px;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    width: max-content;
    column-gap: 5px;
}
/* Etichetele câmpurilor se văd doar pe telefon; pe ecran lat rândul rămâne o grilă de câmpuri. */
.override-field { display: contents; }
.override-field span { display: none; }
.override-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.override-check { display: flex; align-items: center; margin-left: 7px; }
.override-check label { margin-right: 10px; cursor: pointer; white-space: nowrap; }
.override-check input { margin-right: 4px; }
.rules-actions { display: flex; justify-content: flex-end; margin-top: 22px; }
.rules-actions .btn:last-child { margin: 0 0 0 8px; }

/* ---------- Autentificare ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 360px; max-width: calc(100% - 24px); padding: 28px; }
.login-brand { display: flex; align-items: center; margin-bottom: 24px; }
.login-brand > div:last-child { margin-left: 10px; }
.login-brand .brand-name { color: var(--text); }
.login-brand .brand-sub { color: var(--muted); }
.login-submit { width: 100%; margin: 16px 0 0; }
.login-google { margin-top: 0; box-sizing: border-box; text-decoration: none; }
.login-error { margin-top: 10px; color: var(--cal-unassigned-text); font-size: 12px; }

/* ---------- Mesaj de eroare Blazor ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ---------- Telefon ---------- */
@media (max-width: 760px) {
    html, body { font-size: 13px; }
    h1 { font-size: 21px; }

    /* Sub 16px, iOS mărește pagina la fiecare atingere a unui câmp. */
    select.field, .text-field { font-size: 16px; }

    .app { display: block; }

    /* Meniul lateral devine antet: sigla și ieșirea pe primul rând, secțiunile pe o grilă dedesubt. */
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px 12px; }
    .sidebar::before { content: ""; flex-basis: 100%; order: 2; }
    .sidebar .brand { order: 0; flex: 1; }
    .sidebar .brand-name { font-size: 18px; }
    .sidebar-bottom { display: contents; }
    .sidebar-bottom form { order: 1; }
    .sidebar-divider, .sidebar-label, .sidebar-foot { display: none; }
    .sidebar-btn { order: 3; flex: 1 1 30%; width: auto; justify-content: center; margin: 0; padding: 10px 6px; background: var(--sidebar-divider); white-space: nowrap; }
    .sidebar-btn.active { background: var(--primary); }
    .sidebar-bottom .sidebar-btn { flex: none; padding: 8px 12px; }

    .content { padding: 14px 10px 12px; }
    .page-header { margin-bottom: 12px; }
    .page-sub { display: none; }

    .controls { flex-wrap: wrap; padding: 12px; margin-bottom: 10px; }
    .control-group { flex: 1; }
    .control-group select.field, select.field.year { width: 100%; min-width: 0; }
    .controls-divider, .controls-spacer, .controls > .btn { display: none; }
    .control-actions { width: 100%; margin-top: 10px; gap: 8px; align-items: stretch; }
    .control-actions .btn { flex: 1; margin: 0; padding: 11px 8px; white-space: normal; text-align: center; }

    .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
    .summary-card { padding: 12px; }
    .card-value { font-size: 21px; }

    .tabs, .tab-body { padding: 0 6px; }
    .tab { padding: 10px 14px; font-size: 13px; }
    .panel-pad, .panel-pad.large { padding: 12px 8px; overflow-x: auto; }

    /* Calendarul devine listă: o zi pe rând, cu editorul zilei fixat în josul ecranului. */
    .calendar-hint, .weekday-row, .day-cell.empty, .day-caption, .status-badge { display: none; }
    .calendar-title { margin: 0 4px 6px; }
    .mobile-hint { display: block; margin: 0 4px 8px; }
    .day-editor.idle { display: none; }
    .calendar-grid { grid-template-columns: 1fr; margin: 0 0 8px; }
    .day-cell { flex-direction: row; align-items: center; justify-content: flex-start; min-height: 0; margin: 3px 0; padding: 7px 8px; }
    .day-cell.weekend { background: var(--cal-weekend); border-color: var(--cal-weekend-border); }
    .day-top { align-items: center; width: 82px; flex-shrink: 0; }
    .day-number { width: 30px; }
    .day-badge { margin-right: 10px; }
    .day-middle { flex: 1; min-width: 0; margin: 0; }
    .doctor-box { margin: 0; padding: 8px 10px; }

    .day-editor { display: block; position: sticky; bottom: 0; margin: 0 -6px; padding: 10px 12px; border-radius: 10px 10px 0 0; box-shadow: 0 -4px 14px rgba(17, 24, 39, .12); }
    .day-editor-left { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
    .day-editor .card-label { display: none; }
    .selected-date { font-size: 17px; margin: 0; }
    .assign-row { margin: 0; }
    .assign-select { flex: 1; width: auto; min-width: 0; }
    .assign-btn { padding: 11px 16px; }
    .availability-list { max-height: 58px; }

    .grid-table { table-layout: auto; width: 100%; margin-top: 10px; }
    .grid-table th, .grid-table td { padding: 7px 6px; }

    .history-list li { flex-wrap: wrap; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--border); }
    .history-time { width: 100%; }
    .history-user { width: 100%; margin: 0; }
    .history-tabs { margin-top: 10px; }
    .audit-filters { flex-wrap: wrap; }
    .audit-filters select.field { flex: 1 1 100%; }
    .audit-filters .btn { flex: 1; }
    .audit-list .history-time { width: auto; margin-right: 10px; }
    .audit-action { width: auto; }
    .audit-list .history-message { width: 100%; margin-top: 2px; }
    .audit-details { padding-left: 0; }

    .rule-grid, .rule-grid.single { grid-template-columns: 1fr 90px; row-gap: 8px; margin-bottom: 8px; }
    .rule-grid .second, .rule-grid input.second { grid-column: auto; margin-left: 0; width: 100%; }
    .check { margin: 10px 0; }
    .override-list { max-height: none; }
    .override-row { grid-template-columns: 1fr 1fr; width: auto; gap: 10px 8px; padding: 14px 0; }
    .override-name, .override-check { grid-column: 1 / -1; margin-left: 0; }
    .override-name { font-size: 14px; }
    .override-field { display: block; }
    .override-field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
    .override-field input::placeholder { color: transparent; }
    .override-check { order: 1; flex-wrap: wrap; row-gap: 8px; }
    .rules-actions .btn { flex: 1; margin: 0; }

    .statusbar { margin-top: 10px; }
    .status-brand { display: none; }
}
