/* TR Documents -- recreates the Thames Rockets admin (AdminLTE 2.3 skin-blue, recoloured)
   from the design spec's tokens, without reusing AdminLTE/Bootstrap 3. */

:root {
    --tr-red: #F83225;
    --tr-red-dark: #DC2112;
    --tr-navy: #00334E;
    --tr-link-hover: #72AFD2;

    --sidebar-bg: #282828;
    --sidebar-active-bg: #1E282C;
    --sidebar-text: #FFFFFF;
    --sidebar-header: #8AA4AF;
    --content-bg: #ECF0F5;
    --surface: #FFFFFF;

    --text: #333333;
    --text-grid: #2E2E2E;
    --text-muted: #777777;
    --text-muted-btn: #444444;

    --btn-default-bg: #F4F4F4;
    --btn-default-border: #DDDDDD;
    --grid-header-bg: #F4F4F4;
    --grid-alt-row: #F5F5F5;
    --grid-border: #E8E8E8;
    --grid-header-border: #E3E3E3;
    --input-border: #D2D6DE;
    --input-focus: #3C8DBC;

    --success: #6BAC6C;
    --success-border: #02A91E;
    --warning: #F39C12;
    --danger: #D22D2D;
    --notification: #DD4B39;

    /* Swap these two for avenir-next-* once TR confirms a web licence. */
    --font: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-heavy: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    --header-h: 50px;
    --sidebar-w: 230px;
    --sidebar-mini-w: 50px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 20px;
    color: var(--text);
    background: var(--sidebar-bg);
}

a { color: var(--tr-red); text-decoration: none; }
a:hover, a:focus, a:active { color: var(--tr-link-hover); }
b, strong { font-weight: 700; }
code { font-family: Consolas, monospace; }

/* ---------- Shell ---------- */

.wrapper { min-height: 100vh; position: relative; overflow-x: hidden; }

.main-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
    height: var(--header-h); display: flex;
}

.logo {
    width: var(--sidebar-w); height: var(--header-h); flex: none;
    background: var(--tr-red); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; letter-spacing: 1px; transition: width .3s;
    overflow: hidden; white-space: nowrap;
}
.logo:hover, .logo:focus { color: #fff; background: #f9473b; }
.logo b { font-family: var(--font-heavy); font-weight: 900; }
.logo-mini { display: none; font-weight: 900; font-size: 18px; }

.navbar {
    flex: 1; background: var(--tr-red-dark); color: #fff;
    display: flex; align-items: center; justify-content: space-between; min-width: 0;
}
.sidebar-toggle {
    background: none; border: 0; color: #fff; height: var(--header-h); padding: 0 15px;
    font-size: 16px; cursor: pointer;
}
.sidebar-toggle:hover { background: var(--tr-red); }
.navbar-right { display: flex; align-items: center; height: 100%; }
.navbar-right form { margin: 0; height: 100%; }
.nav-item {
    color: #fff; height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 15px;
    background: none; border: 0; font: inherit; cursor: pointer; white-space: nowrap;
}
a.nav-item:hover, button.nav-item:hover { color: #fff; background: rgba(0, 0, 0, .1); }

.main-sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 810;
    width: var(--sidebar-w); background: var(--sidebar-bg);
    overflow-y: auto; transition: width .3s, transform .3s;
}
.sidebar-menu { list-style: none; margin: 0; padding: 0 0 20px; }
.sidebar-menu .header {
    color: var(--sidebar-header); background: #1a1a1a; font-size: 12px;
    padding: 10px 25px 10px 15px; text-transform: uppercase; white-space: nowrap; overflow: hidden;
}
.sidebar-menu a {
    display: flex; align-items: center; gap: 10px; height: 44px; padding: 12px 5px 12px 15px;
    color: var(--sidebar-text); border-left: 3px solid transparent; white-space: nowrap; overflow: hidden;
    text-transform: capitalize;
}
.sidebar-menu a i { width: 20px; text-align: center; flex: none; }
.sidebar-menu a span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-menu a:hover, .sidebar-menu a.active {
    color: #fff; background: var(--sidebar-active-bg); border-left-color: var(--tr-red-dark);
}
.sidebar-menu .label { margin-right: 10px; }

.content-wrapper {
    margin-left: var(--sidebar-w); padding-top: var(--header-h);
    min-height: 100vh; background: var(--content-bg); transition: margin-left .3s;
}
.content { padding: 15px; max-width: 1600px; }

.sidebar-backdrop { display: none; }

/* Desktop: collapse to an icon strip (AdminLTE's sidebar-mini). */
@media (min-width: 768px) {
    .sidebar-collapse .logo { width: var(--sidebar-mini-w); }
    .sidebar-collapse .logo-lg { display: none; }
    .sidebar-collapse .logo-mini { display: inline; }
    .sidebar-collapse .main-sidebar { width: var(--sidebar-mini-w); }
    .sidebar-collapse .sidebar-menu .header,
    .sidebar-collapse .sidebar-menu a span,
    .sidebar-collapse .sidebar-menu .label { display: none; }
    .sidebar-collapse .content-wrapper { margin-left: var(--sidebar-mini-w); }
}

/* Phone (at the piers): sidebar goes off-canvas and slides in over the page. */
@media (max-width: 767px) {
    .logo { width: var(--sidebar-mini-w); }
    .logo-lg { display: none; }
    .logo-mini { display: inline; }
    .main-sidebar { transform: translateX(-100%); }
    .sidebar-open .main-sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 800; background: rgba(0, 0, 0, .4);
    }
    .content-wrapper { margin-left: 0; }
    .hide-xs { display: none !important; }
}
@media (max-width: 991px) {
    .hide-sm { display: none !important; }
}

/* ---------- Page furniture ---------- */

.content-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    margin-bottom: 10px;
}
.page-title {
    font-family: var(--font-heavy); font-weight: 900; font-size: 24px; line-height: 1.1;
    color: var(--tr-navy); margin: 0;
}
.header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.intro { margin: 0 0 15px; }

.breadcrumb { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.breadcrumb li + li::before { content: "/"; color: #ccc; margin-right: 4px; }
.page-breadcrumb { margin: -4px 0 12px; }

.box {
    background: var(--surface); border-radius: 3px; margin-bottom: 20px;
    border-top: 3px solid #d2d6de; box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
.box-header {
    padding: 10px; border-bottom: 1px solid #f4f4f4;
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.box-header .breadcrumb { flex: 1; min-width: 200px; }
.box-title { font-size: 18px; margin: 0; font-weight: 400; }
.box-tool { margin-left: auto; }
.box-body { padding: 10px; }
.box-body.no-padding { padding: 0; }
.table-scroll { overflow-x: auto; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar .search { width: 260px; max-width: 100%; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    font: inherit; font-size: 14px; line-height: 20px; border-radius: 3px; border: 1px solid transparent;
    cursor: pointer; white-space: nowrap; color: #fff;
}
.btn:disabled { opacity: .65; cursor: default; }
.btn-primary { background: var(--tr-navy); border-color: #002538; }
.btn-primary:hover { background: #002538; color: #fff; }
.btn-brand { background: var(--tr-red); border-radius: 2px; }
.btn-brand:hover { background: var(--tr-red-dark); color: #fff; }
.btn-default { background: var(--btn-default-bg); color: var(--text-muted-btn); border-color: var(--btn-default-border); }
.btn-default:hover { background: #e7e7e7; color: #333; }
.btn-success { background: #00a65a; border-color: #008d4c; }
.btn-success:hover { background: #008d4c; color: #fff; }
.btn-danger { background: #dd4b39; border-color: #d73925; }
.btn-danger:hover { background: #d73925; color: #fff; }
.btn-xs { padding: 1px 6px; font-size: 12px; line-height: 1.5; }
.btn-block { width: 100%; justify-content: center; }

.label {
    display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-weight: 700;
    line-height: 16px; color: #fff; vertical-align: middle; margin-left: 4px;
}
.label-red { background: var(--notification); }
.label-warning { background: var(--warning); }
.label-default { background: #d2d6de; color: #444; }

.text-muted { color: var(--text-muted); }
.text-success { color: #008d4c; }
.text-danger { color: var(--danger); font-weight: 700; }
.text-warning { color: #c87f0a; font-weight: 700; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }

/* ---------- Grid (replaces the old Kendo grid look) ---------- */

.grid { width: 100%; border-collapse: collapse; color: var(--text-grid); }
.grid th {
    background: var(--grid-header-bg); font-weight: 700; text-align: left;
    padding: 10px 8px; border-bottom: 1px solid var(--grid-header-border); white-space: nowrap;
}
.grid td { padding: 6px 8px; border-top: 1px solid var(--grid-border); vertical-align: top; }
.grid tbody tr:nth-child(even) { background: var(--grid-alt-row); }
.grid tbody tr:hover { background: #eef4f8; }
.grid tr.selected { background: #fff6e0 !important; }
.grid tr.archived td { color: #999; }
.grid td.actions { text-align: right; white-space: nowrap; }
.grid td.actions .btn { margin-left: 2px; }
.grid td.empty { text-align: center; padding: 30px 8px; color: var(--text-muted); }
.grid .folder-row a { font-weight: 700; }
.grid .folder-row i { color: #e8b04a; }

.progress { display: inline-block; vertical-align: middle; width: 80px; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; margin-right: 6px; }
.progress-bar { height: 100%; background: var(--success); }

.reject-form { display: flex; gap: 4px; margin-top: 4px; justify-content: flex-end; }
.reject-form .form-control { width: 220px; padding: 2px 6px; height: auto; }

/* ---------- Forms ---------- */

.form-control {
    display: block; width: 100%; padding: 6px 12px; font: inherit; color: #555;
    border: 1px solid var(--input-border); border-radius: 0; background: #fff;
}
.form-control:focus { outline: 0; border-color: var(--input-focus); }
.form-control.narrow { max-width: 320px; }
.form-horizontal .form-group {
    display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 15px; align-items: start; margin-bottom: 15px;
}
.form-horizontal .form-group > label:first-child { font-weight: 700; padding-top: 7px; text-align: right; }
@media (max-width: 767px) {
    .form-horizontal .form-group { grid-template-columns: 1fr; }
    .form-horizontal .form-group > label:first-child { text-align: left; padding-top: 0; }
    .form-horizontal .form-group > label:first-child:empty { display: none; }
}
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; padding-top: 7px; }
.radio-list { display: flex; flex-direction: column; gap: 8px; padding-top: 7px; }
.radio-list label { display: block; }

.drop-zone {
    position: relative; border: 2px dashed var(--input-border); background: #fafafa;
    padding: 28px 16px; text-align: center; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.drop-zone:hover { border-color: var(--input-focus); }
.drop-zone.has-file { border-color: var(--success); color: var(--text); background: #f3faf3; }
.drop-zone i { font-size: 28px; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.alert { padding: 12px 15px; margin: 0 0 15px; border: 1px solid transparent; border-radius: 3px; }
.alert-danger { background: #f2dede; border-color: #ebccd1; color: #a94442; }
.alert-warning { background: #fcf8e3; border-color: #faebcc; color: #8a6d3b; }
.alert-success { background: var(--success); border-color: var(--success-border); color: #fff; }
.alert .copy { display: block; margin-top: 6px; padding: 6px 8px; background: rgba(255, 255, 255, .9); color: #333; word-break: break-all; user-select: all; }

/* ---------- Document detail ---------- */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0 20px; }
@media (max-width: 991px) { .detail-grid { grid-template-columns: 1fr; } }
.viewer { display: block; width: 100%; height: 75vh; border: 0; }
.viewer-media { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; }
.no-preview { padding: 40px 16px; text-align: center; color: var(--text-muted); }
.no-preview i { font-size: 40px; }
.meta { margin: 0; }
.meta dt { font-weight: 700; margin-top: 8px; }
.meta dt:first-child { margin-top: 0; }
.meta dd { margin: 0; }

/* ---------- Sign-in pages ---------- */

.auth-page { background: var(--content-bg); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; }
.auth-box { width: 100%; max-width: 360px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.auth-logo { background: var(--tr-red); color: #fff; text-align: center; font-size: 22px; letter-spacing: 1px; padding: 14px; }
.auth-logo b { font-weight: 900; }
.auth-body { padding: 20px; }
.auth-body h1 { font-family: var(--font-heavy); font-weight: 900; color: var(--tr-navy); font-size: 20px; margin: 0 0 15px; }
.auth-body label { display: block; font-weight: 700; margin-bottom: 12px; }
.auth-body label .form-control { margin-top: 4px; font-weight: 400; }
.auth-body .text-muted { font-size: 13px; margin: 15px 0 0; }

/* ---------- Blazor connection banners ---------- */

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 2000;
    background: #fff3cd; padding: 10px 16px; box-shadow: 0 -1px 3px rgba(0, 0, 0, .2);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: block; position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 2000;
    background: #fff; padding: 12px 20px; border-top: 3px solid var(--tr-red); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.reconnect-msg { display: none; }
.components-reconnect-show .reconnect-msg-show,
.components-reconnect-failed .reconnect-msg-failed,
.components-reconnect-rejected .reconnect-msg-rejected { display: block; }
