/* CREBOOK-CSS-VERSION: 0.4.1-fluent2 */
/* =====================================================================
   CREBOOK – vzhled administrace
   Postaveno na design tokenech Fluent 2 (Microsoft): neutrální rampa,
   značková rampa Communication Blue, typografická škála, poloměry,
   elevace a křivky animací.
   Ikony: Fluent UI System Icons (MIT) v public/assets/icons.svg.
   ===================================================================== */

:root {
    /* --- značková rampa (Fluent Communication Blue) --- */
    --brand-10:  #061724;
    --brand-40:  #0c3b5e;
    --brand-60:  #0f548c;
    --brand-70:  #115ea3;
    --brand-80:  #0f6cbd;   /* primární */
    --brand-90:  #2886de;
    --brand-100: #479ef5;
    --brand-140: #b4d6fa;
    --brand-150: #cfe4fa;
    --brand-160: #ebf3fc;

    --brand-bg:          var(--brand-80);
    --brand-bg-hover:    var(--brand-70);
    --brand-bg-pressed:  var(--brand-40);
    --brand-bg-selected: var(--brand-60);
    --brand-bg-tint:     var(--brand-160);
    --brand-stroke-tint: var(--brand-140);
    --brand-fg:          var(--brand-80);
    --brand-fg-hover:    var(--brand-70);

    /* --- neutrální rampa --- */
    --bg-1:        #ffffff;
    --bg-1-hover:  #f5f5f5;
    --bg-1-press:  #e0e0e0;
    --bg-2:        #fafafa;
    --bg-3:        #f5f5f5;
    --bg-4:        #f0f0f0;
    --bg-canvas:   #f5f5f5;
    --bg-disabled: #f0f0f0;

    --fg-1:        #242424;
    --fg-2:        #424242;
    --fg-3:        #616161;
    --fg-4:        #707070;
    --fg-disabled: #bdbdbd;
    --fg-on-brand: #ffffff;

    --stroke-1:          #d1d1d1;
    --stroke-2:          #e0e0e0;
    --stroke-3:          #f0f0f0;
    --stroke-accessible: #616161;

    /* --- stavové barvy --- */
    --ok-bg: #f1faf1;  --ok-fg: #0e700e;  --ok-stroke: #9fd89f;
    --err-bg: #fdf3f4; --err-fg: #b10e1c; --err-stroke: #f1bbbc;
    --warn-bg: #fff9f5; --warn-fg: #bc4b09; --warn-stroke: #f4bfab;

    /* --- poloměry --- */
    --r-s:  2px;
    --r-m:  4px;
    --r-l:  6px;
    --r-xl: 8px;
    --r-circular: 9999px;

    /* --- elevace --- */
    --shadow-2:  0 1px 2px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
    --shadow-4:  0 2px 4px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
    --shadow-8:  0 4px 8px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
    --shadow-16: 0 8px 16px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
    --shadow-28: 0 14px 28px rgba(0,0,0,.24), 0 0 8px rgba(0,0,0,.20);

    /* --- pohyb --- */
    --dur-faster: 100ms;
    --dur-normal: 200ms;
    --curve-ease: cubic-bezier(.33, 0, .67, 1);
    --curve-decel: cubic-bezier(.1, .9, .2, 1);

    /* --- rozměry --- */
    --rail: 260px;
    --topbar: 48px;

    /* --- typografie --- */
    --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
            Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI",
            -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg-canvas);
    color: var(--fg-1);
    font-family: var(--font);
    font-size: 14px;          /* body1 */
    line-height: 20px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* --- typografická škála --- */
h1, h2, h3 { font-family: var(--font-display); margin: 0 0 4px; font-weight: 600; }
h1 { font-size: 24px; line-height: 32px; letter-spacing: -.01em; }  /* title3 */
h2 { font-size: 16px; line-height: 22px; }                          /* subtitle2 */
h3 { font-size: 14px; line-height: 20px; }
p  { margin: 0 0 12px; }

a { color: var(--brand-fg); text-decoration: none; }
a:hover { color: var(--brand-fg-hover); text-decoration: underline; }

code {
    font-family: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
    font-size: 13px;
    background: var(--bg-3);
    border-radius: var(--r-s);
    padding: 1px 4px;
}

:focus-visible {
    outline: 2px solid var(--fg-1);
    outline-offset: 1px;
    border-radius: var(--r-m);
}

/* --- ikony --- */
.ic { flex: 0 0 auto; vertical-align: -.15em; }

/* =====================================================================
   Rozvržení
   ===================================================================== */

.shell { display: flex; min-height: 100vh; }

.rail {
    width: var(--rail);
    flex: 0 0 var(--rail);
    background: var(--bg-1);
    border-right: 1px solid var(--stroke-2);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    height: var(--topbar);
    flex: 0 0 var(--topbar);
    border-bottom: 1px solid var(--stroke-3);
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--r-l);
    background: var(--brand-bg);
    color: var(--fg-on-brand);
}
.brand strong {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .01em;
}
.brand span { color: var(--fg-3); font-size: 12px; line-height: 16px; display: block; }

.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav-group {
    padding: 16px 12px 4px;
    color: var(--fg-3);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    margin-bottom: 2px;
    color: var(--fg-1);
    text-decoration: none;
    border-radius: var(--r-m);
    position: relative;
    transition: background var(--dur-faster) var(--curve-ease);
}
.nav a .ic { color: var(--fg-3); }
.nav a:hover { background: var(--bg-1-hover); color: var(--fg-1); text-decoration: none; }
.nav a.is-active { background: var(--brand-bg-tint); color: var(--brand-bg-selected); font-weight: 600; }
.nav a.is-active .ic { color: var(--brand-bg); }
.nav a.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    border-radius: var(--r-circular);
    background: var(--brand-bg);
}
.nav .nav-sub a { padding-left: 12px; }

.rail-foot {
    padding: 8px;
    border-top: 1px solid var(--stroke-3);
}
.rail-foot a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--r-m);
    color: var(--fg-1);
}
.rail-foot a:hover { background: var(--bg-1-hover); text-decoration: none; }
.rail-foot .who { color: var(--fg-3); font-size: 12px; line-height: 16px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar);
    padding: 0 24px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--stroke-2);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar form { display: flex; align-items: center; gap: 8px; margin: 0; }
.topbar .who { color: var(--fg-3); font-size: 12px; }
.topbar-tenant { display: flex; align-items: center; gap: 8px; }
.topbar select { height: 28px; min-width: 190px; }

.content { padding: 24px; max-width: 1240px; width: 100%; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head p { color: var(--fg-3); margin: 4px 0 0; max-width: 70ch; }

/* =====================================================================
   Povrchy
   ===================================================================== */

.panel {
    background: var(--bg-1);
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
    margin-bottom: 16px;
    overflow: hidden;
}
.panel-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--stroke-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.panel-head h2 { margin: 0; }
.panel-body { padding: 16px; }
.panel-body > :last-child { margin-bottom: 0; }

.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.stat {
    background: var(--bg-1);
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
    padding: 16px;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.stat-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-l);
    background: var(--brand-bg-tint);
    color: var(--brand-bg);
}
.stat b {
    display: block;
    font-family: var(--font-display);
    font-size: 28px;
    line-height: 36px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.stat span { color: var(--fg-3); font-size: 12px; line-height: 16px; }

/* =====================================================================
   Tabulky
   ===================================================================== */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    padding: 8px 16px;
    text-align: left;
    color: var(--fg-2);
    font-weight: 600;
    font-size: 12px;
    line-height: 16px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--stroke-2);
    white-space: nowrap;
}
tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--stroke-3);
    vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur-faster) var(--curve-ease); }
tbody tr:hover { background: var(--bg-1-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td .who { color: var(--fg-3); font-size: 12px; line-height: 16px; }

/* =====================================================================
   Odznaky
   ===================================================================== */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-circular);
    background: var(--bg-3);
    color: var(--fg-2);
    font-size: 12px;
    line-height: 18px;
    font-weight: 600;
    white-space: nowrap;
}
.tag-role { background: var(--brand-bg-tint); border-color: var(--brand-stroke-tint); color: var(--brand-bg-selected); }
.tag-on   { background: var(--ok-bg);  border-color: var(--ok-stroke);  color: var(--ok-fg); }
.tag-off  { background: var(--err-bg); border-color: var(--err-stroke); color: var(--err-fg); }

/* =====================================================================
   Formuláře
   ===================================================================== */

.field { margin-bottom: 16px; }
.field > label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--fg-1);
}
.field .hint { font-size: 12px; line-height: 16px; color: var(--fg-3); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=search], input[type=date], select, textarea {
    width: 100%;
    min-height: 32px;
    padding: 5px 10px;
    background: var(--bg-1);
    color: var(--fg-1);
    font: inherit;
    border: 1px solid var(--stroke-1);
    border-bottom-color: var(--stroke-accessible);
    border-radius: var(--r-m);
    transition: border-color var(--dur-faster) var(--curve-ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--fg-4); border-bottom-color: var(--stroke-accessible); }

/* Fluent: při zaměření se zvýrazní spodní hrana značkovou barvou */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--stroke-1);
    border-bottom: 2px solid var(--brand-bg);
    padding-bottom: 4px;
}
input[disabled], select[disabled], textarea[disabled] {
    background: var(--bg-disabled);
    color: var(--fg-disabled);
    border-color: var(--stroke-3);
}
textarea { min-height: 88px; resize: vertical; line-height: 20px; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23616161'%3E%3Cpath d='M4.22 8.47a.75.75 0 0 1 1.06 0L12 15.19l6.72-6.72a.75.75 0 1 1 1.06 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L4.22 9.53a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
}

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.check input[type=checkbox] {
    appearance: none;
    width: 16px; height: 16px;
    margin: 2px 0 0;
    border: 1px solid var(--stroke-accessible);
    border-radius: var(--r-s);
    background: var(--bg-1);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--dur-faster) var(--curve-ease);
}
.check input[type=checkbox]:checked {
    background: var(--brand-bg) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8.98 16.6 4.7 12.32a.75.75 0 0 0-1.06 1.06l4.8 4.8c.3.3.78.3 1.07 0L20.36 7.34a.75.75 0 0 0-1.06-1.06L8.98 16.6Z'/%3E%3C/svg%3E") center/12px no-repeat;
    border-color: var(--brand-bg);
}
.check label { margin: 0; font-weight: 400; color: var(--fg-1); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.error-text { color: var(--err-fg); font-size: 12px; line-height: 16px; margin-top: 4px; }
input.has-error, select.has-error, textarea.has-error { border-color: var(--err-fg); }

/* =====================================================================
   Tlačítka
   ===================================================================== */

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions.right { justify-content: flex-end; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--r-m);
    background: var(--brand-bg);
    color: var(--fg-on-brand);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-faster) var(--curve-ease);
}
.btn:hover { background: var(--brand-bg-hover); color: var(--fg-on-brand); text-decoration: none; }
.btn:active { background: var(--brand-bg-pressed); }

.btn-ghost {
    background: var(--bg-1);
    border-color: var(--stroke-1);
    color: var(--fg-1);
}
.btn-ghost:hover { background: var(--bg-1-hover); border-color: var(--stroke-1); color: var(--fg-1); }
.btn-ghost:active { background: var(--bg-1-press); }

.btn-danger { background: var(--err-fg); }
.btn-danger:hover { background: #a4262c; }

.btn-small { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-link {
    background: none; border: none; padding: 0; height: auto;
    color: var(--brand-fg); cursor: pointer; font: inherit; text-decoration: underline;
}

.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; min-width: 160px; }

/* =====================================================================
   Hlášky (MessageBar)
   ===================================================================== */

.flash { margin-bottom: 16px; }
.flash div {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-m);
    background: var(--bg-2);
    margin-bottom: 8px;
    font-size: 14px;
}
.flash .success { background: var(--ok-bg);  border-color: var(--ok-stroke);  color: var(--ok-fg); }
.flash .error   { background: var(--err-bg); border-color: var(--err-stroke); color: var(--err-fg); }
.flash .info    { background: var(--brand-bg-tint); border-color: var(--brand-stroke-tint); color: var(--brand-bg-selected); }
.flash .ic { margin-top: 2px; }

.empty { padding: 40px 16px; text-align: center; color: var(--fg-3); }
.empty .ic { color: var(--fg-disabled); margin-bottom: 8px; }
.empty p { margin-bottom: 12px; }

.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--stroke-3);
    color: var(--fg-3);
    font-size: 12px;
}
.pagination a, .pagination span.current {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--stroke-1);
    border-radius: var(--r-m);
    font-size: 14px;
    text-decoration: none;
    color: var(--fg-1);
}
.pagination a:hover { background: var(--bg-1-hover); text-decoration: none; }
.pagination .current { background: var(--brand-bg); border-color: var(--brand-bg); color: var(--fg-on-brand); font-weight: 600; }

/* =====================================================================
   Přihlášení
   ===================================================================== */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(1200px 600px at 50% -10%, var(--brand-160), transparent 70%),
        var(--bg-canvas);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-1);
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-16);
    padding: 28px 28px 24px;
}
.auth-card h1 { font-size: 20px; line-height: 26px; margin-bottom: 4px; }
.auth-card .lead { color: var(--fg-3); margin-bottom: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-brand strong { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.auth-brand span { color: var(--fg-3); font-size: 12px; display: block; }
.auth-card .btn { width: 100%; }
.auth-foot { margin-top: 16px; font-size: 14px; }
.auth-note { color: var(--fg-3); font-size: 12px; text-align: center; margin-top: 16px; }

/* =====================================================================
   Kalendář obsazenosti
   ===================================================================== */

.cal-wrap { overflow-x: auto; }

table.cal { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
table.cal th, table.cal td {
    border-right: 1px solid var(--stroke-3);
    border-bottom: 1px solid var(--stroke-3);
    padding: 0;
    text-align: center;
}
table.cal thead th {
    padding: 6px 2px;
    min-width: 28px;
    background: var(--bg-2);
    color: var(--fg-3);
    font-weight: 600;
}
table.cal thead th.is-weekend { background: var(--bg-4); color: var(--fg-2); }
table.cal thead th.is-today { background: var(--brand-bg); color: var(--fg-on-brand); }

th.cal-unit {
    text-align: left;
    padding: 8px 16px;
    min-width: 220px;
    position: sticky;
    left: 0;
    background: var(--bg-1);
    z-index: 2;
    font-weight: 600;
    border-right: 1px solid var(--stroke-2);
}
thead th.cal-unit { background: var(--bg-2); z-index: 3; }
th.cal-unit .who { display: block; color: var(--fg-3); font-weight: 400; font-size: 12px; }
th.cal-unit .tag { margin-left: 6px; }

table.cal td { height: 34px; }
table.cal td a { display: block; height: 34px; line-height: 34px; text-decoration: none; color: inherit; }

.cal-free { background: var(--bg-1); }
.cal-free.is-weekend { background: var(--bg-2); }
.cal-free a:hover { background: var(--brand-bg-tint); }

.cal-res { color: var(--fg-on-brand); font-weight: 600; }
.cal-new       { background: var(--fg-4); }
.cal-confirmed { background: var(--brand-100); }
.cal-paid      { background: var(--brand-80); }
.cal-completed { background: var(--brand-60); }
.cal-block, .cal-blocked {
    background: repeating-linear-gradient(45deg, var(--bg-4), var(--bg-4) 4px, #e2e2e2 4px, #e2e2e2 8px);
    color: var(--fg-4);
}

.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--fg-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-swatch { display: inline-block; width: 12px; height: 12px; border-radius: var(--r-s); }

/* =====================================================================
   Responzivita
   ===================================================================== */

@media (max-width: 1000px) {
    .shell { flex-direction: column; }
    .rail { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--stroke-2); }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .nav-group { width: 100%; padding: 8px 8px 0; }
    .nav .nav-sub { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
    .nav a { margin-bottom: 0; }
    .nav a.is-active::before { display: none; }
    .rail-foot { display: none; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .topbar { height: auto; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
