:root {
    --dp-owed: #b3261e;
    --dp-paid: #1b7a3e;
    --dp-muted: var(--rz-text-secondary-color, #5f6368);

    /* Χρώματα από το λογότυπο: πράσινο #add950 και γκρι-μπλε #576371.
       Το primary είναι σκουρότερη απόχρωση του πράσινου ώστε το λευκό κείμενο στα κουμπιά να διαβάζεται. */
    --dp-brand-green: #add950;
    --dp-brand-slate: #576371;
    --rz-primary: #557a14;
    --rz-primary-light: #6b9722;
    --rz-primary-lighter: rgba(173, 217, 80, 0.22);
    --rz-primary-dark: #466610;
    --rz-primary-darker: #38520c;
    --rz-on-primary: #ffffff;
    --rz-on-primary-lighter: #3f5a0e;
    --rz-header-background-color: var(--dp-brand-slate);
    --rz-header-color: #ffffff;

    /* Χωρίς ΚΕΦΑΛΑΙΑ σε κουμπιά, tabs κτλ. (στα ελληνικά χάνονται και οι τόνοι). */
    --rz-tabs-tab-text-transform: none;
    --rz-text-button-text-transform: none;
    --rz-badge-text-transform: none;
    --rz-scheduler-header-text-transform: none;
    --rz-datepicker-calendar-header-text-transform: none;
}

.rz-button-lg, .rz-button-md, .rz-button-sm, .rz-button-xs,
.rz-fileupload .rz-button, .rz-pager-element, .rz-timepicker .rz-button-md {
    text-transform: none;
    letter-spacing: normal;
}

html, body {
    margin: 0;
    background: var(--rz-base-background-color, #f5f5f5);
}

h1:focus { outline: none; }

.muted { color: var(--dp-muted); }
.small { font-size: 0.8125rem; }
.pre-wrap { white-space: pre-wrap; }
.tabular { font-variant-numeric: tabular-nums; }
.text-owed { color: var(--dp-owed); }
.text-paid { color: var(--dp-paid); }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
    box-sizing: border-box;
    background: linear-gradient(160deg, #eef6dc 0%, #f5f5f5 60%);
    font-family: var(--rz-text-font-family, system-ui, sans-serif);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-sizing: border-box;
}

.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand img { width: 150px; height: auto; }

.login-card label { display: block; font-size: 0.875rem; margin: 14px 0 4px; }

.login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #c4c7c5;
    border-radius: 6px;
    font-size: 1rem;
}

.login-input:focus { outline: 2px solid var(--rz-primary, #1976d2); border-color: transparent; }

.login-remember { display: flex !important; gap: 8px; align-items: center; }

.login-submit { width: 100%; margin-top: 20px; justify-content: center; }

.login-error {
    background: #fdecea;
    color: #8c1d18;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.validation-message { color: #b3261e; font-size: 0.8125rem; }

/* ---------- Layout ---------- */
.app-layout { min-height: 100vh; }

.rz-header { background-color: var(--dp-brand-slate); color: #fff; }
.rz-header .rz-sidebar-toggle, .rz-header .rz-sidebar-toggle .rzi { color: #fff; }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand img { width: 34px; height: 34px; display: block; }
.brand-name { font-size: 1.125rem; font-weight: 600; line-height: 1.1; }
.brand-sub { font-size: 0.75rem; color: var(--dp-brand-green); line-height: 1.1; }

/* Κουμπί αποσύνδεσης: ρητά χρώματα ώστε να φαίνεται πάνω στη σκούρα κεφαλίδα. */
.logout-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 6px;
    padding: 6px 12px;
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}
.logout-button:hover { background: rgba(255, 255, 255, 0.12); }
.logout-button:focus-visible { outline: 2px solid var(--dp-brand-green); outline-offset: 2px; }
.logout-button .rzi { font-size: 1.25rem; }

.clickable-rows .rz-data-row { cursor: pointer; }
.past-row { opacity: 0.6; }

/* ---------- Stat cards ---------- */
.stat-card { position: relative; height: 100%; box-sizing: border-box; }
.stat-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.stat-link:focus-visible { outline: 2px solid var(--rz-primary); }
.stat-icon { font-size: 2rem !important; padding: 10px; border-radius: 50%; background: var(--rz-primary-lighter); color: var(--rz-primary); }
.stat-warning .stat-icon { background: #fff3e0; color: #e65100; }
.stat-success .stat-icon { background: #e8f5e9; color: var(--dp-paid); }
.stat-label { font-size: 0.8125rem; color: var(--dp-muted); }
.stat-value { font-size: 1.375rem; font-weight: 600; }

/* ---------- Lists ---------- */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--rz-base-200, #eee);
}
.plain-list li:last-child { border-bottom: 0; }

.info-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 0;
}
.info-list dt { color: var(--dp-muted); font-size: 0.875rem; }
.info-list dd { margin: 0; overflow-wrap: anywhere; }
.info-list.compact { gap: 4px 12px; font-size: 0.9rem; }

.medical-alert {
    background: #fff4e5;
    border-left: 3px solid #e65100;
    padding: 8px 12px;
    border-radius: 4px;
}

.balance-chip {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
}
.balance-chip.owed { background: #fdecea; color: var(--dp-owed); }
.balance-chip.clear { background: #e8f5e9; color: var(--dp-paid); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 100px 1fr; gap: 12px; margin-bottom: 12px; }
.timeline-date { padding-top: 16px; font-weight: 600; color: var(--dp-muted); }
.next-steps { color: var(--rz-primary); display: flex; gap: 6px; align-items: flex-start; }

/* ---------- Files ---------- */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.file-tile {
    background: var(--rz-base-background-color, #fff);
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--rz-shadow-1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-thumb {
    aspect-ratio: 4 / 3;
    border: 0;
    padding: 0;
    cursor: pointer;
    background: #263238;
    color: #cfd8dc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb:focus-visible { outline: 3px solid var(--rz-primary); outline-offset: -3px; }
.file-icon { font-size: 3rem !important; }
.file-ext { font-size: 0.75rem; letter-spacing: 0.08em; }

.file-meta { padding: 8px 10px 0; min-width: 0; }
.file-name { font-weight: 500; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-actions { display: flex; justify-content: flex-end; padding: 2px 4px 4px; }

/* ---------- Viewer ---------- */
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-body {
    flex: 1;
    min-height: min(68vh, 680px);
    position: relative;
    background: #1e2227;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.viewer-image { max-width: 100%; max-height: 72vh; display: block; }
.viewer-3d { position: absolute; inset: 0; touch-action: none; }
.viewer-pdf { width: 100%; height: 100%; min-height: 70vh; border: 0; background: #fff; }
.viewer-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    color: #eceff1;
    text-align: center;
    padding: 16px;
}
.viewer-overlay.static { position: static; }

/* ---------- Calendar ---------- */
.calendar { height: calc(100vh - 170px); min-height: 520px; }
.appt-text.cancelled { text-decoration: line-through; }

/* ---------- Responsive ---------- */
.show-mobile { display: none; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block; }

    .brand-text { display: none; }
    .logout-button { padding: 6px 8px; }

    /* Οι πίνακες προσαρμόζονται στο πλάτος αντί για σταθερές στήλες. */
    .rz-data-grid table { table-layout: auto !important; width: 100% !important; }
    .rz-data-grid col { width: auto !important; }
    .rz-data-grid th, .rz-data-grid td { min-width: 0 !important; }

    .rz-body { padding: 0; }

    .timeline li { grid-template-columns: 1fr; gap: 4px; }
    .timeline-date { padding-top: 0; }

    .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

    .stat-value { font-size: 1.125rem; }

    .calendar { height: calc(100vh - 150px); min-height: 460px; }

    /* Τα tabs γίνονται οριζόντια κυλιόμενα αντί να σπάνε σε πολλές γραμμές. */
    .patient-tabs .rz-tabview-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .patient-tabs .rz-tabview-nav li { flex: 0 0 auto; }

    /* Οι διάλογοι πιάνουν όλη την οθόνη στο κινητό. */
    .rz-dialog:not(.rz-dialog-confirm) {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0;
    }

    .form-actions { position: sticky; bottom: 0; background: var(--rz-base-background-color); padding: 8px 0; }
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    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; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Παρουσιάστηκε σφάλμα."; }
