/* Shared application layout, adapted from preview.html for Bootstrap 4. */
.app-body {
    --app-header-height: 64px;
    --app-sidebar-width: 260px;
    --app-primary: #0d6efd;
    --app-sidebar-bg: #1f2937;
    margin: 0;
    min-height: 100vh;
    background: #f5f7fa;
    color: #212529;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.app-icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-icon { display: inline-block; width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; }
.app-header { position: fixed; z-index: 1030; top: 0; left: 0; right: 0; height: var(--app-header-height); border-bottom: 1px solid #e5e7eb; background: #fff; }
.app-header-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 24px; }
.app-header-brand, .app-header-actions { display: flex; align-items: center; gap: 20px; min-width: 0; }
.app-logo { display: inline-flex; align-items: center; gap: 9px; color: #212529; font-size: 1.2rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.app-logo:hover { color: #212529; text-decoration: none; }
.app-logo .app-brand-icon { width: 25px; height: 25px; color: var(--app-primary); }
.app-user { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: #6c757d; font-size: .875rem; }
.app-user .app-icon { font-size: 1.18rem; }
.app-user-name { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-logout-form { margin: 0; }
.app-logout { display: inline-flex; align-items: center; gap: 6px; padding: .35rem .65rem; white-space: nowrap; }
.app-menu-toggle, .app-sidebar-close { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 6px; background: #f8f9fa; color: #293241; font-size: 1.4rem; cursor: pointer; }
.app-menu-toggle:hover { background: #e9ecef; }

.app-sidebar { position: fixed; z-index: 1020; top: var(--app-header-height); bottom: 0; left: 0; width: var(--app-sidebar-width); padding: 16px; overflow-y: auto; background: var(--app-sidebar-bg); color: #fff; }
.app-nav { display: flex; flex-direction: column; }
.app-nav-link { display: flex; align-items: center; gap: 13px; min-height: 46px; margin-bottom: 4px; padding: 10px 13px; border-radius: 8px; color: #d1d5db; font-size: .95rem; line-height: 1.2; text-decoration: none; }
.app-nav-link .app-icon { width: 20px; height: 20px; }
.app-nav-link:hover { background: #374151; color: #fff; text-decoration: none; }
.app-nav-link.active, .app-nav-link.active:hover { background: var(--app-primary); color: #fff; }
.app-sidebar-mobile-head, .app-sidebar-backdrop { display: none; }

.app-main { min-height: 100vh; margin-left: var(--app-sidebar-width); padding: calc(var(--app-header-height) + 32px) 32px 32px; }
.app-content { width: 100%; padding: 0; }
.app-content .breadcrumb { margin: 0 0 18px; padding: 0; background: transparent; color: #6c757d; font-size: .875rem; }
.app-content .breadcrumb a { color: #6c757d; text-decoration: none; }
.app-content .breadcrumb a:hover { color: var(--app-primary); text-decoration: underline; }
.app-content h1 { margin: 0 0 8px; color: #212529; font-size: 1.75rem; font-weight: 600; }
.app-content h2, .app-content h3 { color: #212529; }
.app-content .btn { border-radius: 6px; }
.app-content .btn-success { border-color: #198754; background: #198754; }
.app-content .btn-success:hover { border-color: #157347; background: #157347; }
.app-content .form-control, .app-content .custom-select { border-color: #ced4da; border-radius: 6px; }
.app-content .form-control:focus, .app-content .custom-select:focus { border-color: #86b7fe; box-shadow: 0 0 0 .2rem rgba(13,110,253,.14); }
.app-content .form-group label { color: #6c757d; font-size: .85rem; font-weight: 600; }
.app-content .alert { border-radius: 8px; }

/* Existing CRUD screens keep their Yii widgets and gain the same page rhythm. */
.app-content div[class$="-index"] > h1 { display: inline-block; margin-bottom: 22px; vertical-align: middle; }
.app-content div[class$="-index"] > h1 + p { float: right; margin: 0 0 22px; }
.app-content div[class$="-index"] > h1 + p .btn { padding: 9px 16px; }
.app-content div[class$="-index"] > .grid-view { clear: both; }
.app-content .grid-view { overflow-x: auto; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.app-content .grid-view .summary { padding: 16px 16px 10px; color: #6c757d; font-size: .875rem; }
.app-content .grid-view .table { min-width: 680px; margin: 0; background: #fff; }
.app-content .grid-view .table thead th { padding: 13px 16px; border-top: 0; border-bottom: 1px solid #dee2e6; background: #f8f9fa; color: #6c757d; font-size: .8rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.app-content .grid-view .table tbody td { padding: 13px 16px; border-color: #e9ecef; vertical-align: middle; }
.app-content .grid-view .table tbody tr:hover { background: #f8f9fa; }
.app-content .grid-view .filters td { padding: 8px 12px; border-color: #e9ecef; background: #f8f9fa; }
.app-content .grid-view .filters input, .app-content .grid-view .filters select { width: 100%; min-height: 34px; border: 1px solid #ced4da; border-radius: 6px; }
.app-content .grid-view .pagination { margin: 16px; }
.app-content .grid-view .action-column { width: 145px; white-space: nowrap; text-align: center; }
.app-content .grid-view .action-column a { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; margin: 0 2px; border: 0; border-radius: 6px; background: #f1f5f9; color: var(--app-primary); font-size: 0; vertical-align: middle; text-decoration: none; }
.app-content .grid-view .action-column a:hover { background: #e2ecfa; }
.app-content .grid-view .action-column a:before { font-size: 18px; }
.app-content .grid-view .action-column a[title="View"]:before, .app-content .grid-view .action-column a[aria-label="View"]:before { content: '◉'; }
.app-content .grid-view .action-column a[title="Update"]:before, .app-content .grid-view .action-column a[aria-label="Update"]:before { content: '✎'; }
.app-content .grid-view .action-column a[title="Delete"], .app-content .grid-view .action-column a[aria-label="Delete"] { color: #dc3545; }
.app-content .grid-view .action-column a[title="Delete"]:before, .app-content .grid-view .action-column a[aria-label="Delete"]:before { content: '×'; font-size: 23px; }
.app-content div[class$="-form"] { max-width: 980px; padding: 24px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.app-content .detail-view { margin-top: 20px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; }
.app-content .detail-view th, .app-content .detail-view td { padding: 13px 16px; border-color: #e9ecef; }
.app-content .detail-view th { width: 220px; background: #f8f9fa; color: #6c757d; font-weight: 600; }
.app-content .card { border-color: #e5e7eb; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }

/* Contracts list matches the filter, count and table structure in the prototype. */
.app-page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.app-page-heading h1 { margin-bottom: 2px; }
.app-page-heading p { margin: 0; color: #6c757d; }
.app-page-heading .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px; white-space: nowrap; }
.app-card { overflow: hidden; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.contracts-filter { margin: 16px; padding: 16px; border-radius: 10px; background: #f8f9fa; }
.contracts-filter-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.contracts-filter-field { flex: 1 1 240px; min-width: 180px; }
.contracts-filter-field label { display: block; margin-bottom: 6px; color: #6c757d; font-size: .8rem; font-weight: 600; }
.contracts-filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.contracts-filter-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; }
.contracts-extra { margin-top: 14px; }
.contracts-extra summary { color: #6c757d; font-size: .85rem; cursor: pointer; }
.contracts-extra-fields { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.contracts-extra-fields .contracts-filter-field { max-width: 240px; }
.contracts-counter { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px 16px; color: #6c757d; font-size: .875rem; }
.contracts-counter strong { color: #212529; }
.contracts-show-all { display: inline-flex; align-items: center; gap: 7px; margin: 0; white-space: nowrap; cursor: pointer; }
.contracts-show-all input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.app-table-scroll { overflow-x: auto; }
.app-content .contracts-grid { overflow: visible; border: 0; border-radius: 0; box-shadow: none; }
.app-content .contracts-grid .table { min-width: 760px; white-space: nowrap; }
.app-content .contracts-grid .table thead th { padding: 13px 16px; }
.app-content .contracts-grid .table tbody td { padding: 13px 16px; }
.app-content .contracts-grid .table tbody td a:not(.app-action) { color: #0d6efd; font-weight: 500; text-decoration: none; }
.app-content .contracts-grid .table tbody td a:not(.app-action):hover { text-decoration: underline; }
.app-content .contracts-grid .app-action { width: 34px; height: 34px; margin: 0 2px; padding: 0; font-size: 1rem; }
.app-content .contracts-grid .app-action .app-icon { width: 17px; height: 17px; }
.app-content .contracts-grid .app-action-danger { color: #dc3545; }
.app-content .contracts-grid .app-action-danger:hover { background: #fff0f1; color: #c82333; }
.contracts-pagination { padding: 14px 16px; border-top: 1px solid #e9ecef; }
.contracts-pagination .pagination { margin: 0; }

.app-dashboard-grid { margin-top: 2px; }
.app-dashboard-card { display: flex; align-items: center; gap: 15px; height: 100%; min-height: 108px; padding: 20px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); color: #212529; text-decoration: none; }
.app-dashboard-card:hover { border-color: #b6d4fe; box-shadow: 0 5px 20px rgba(13,110,253,.09); color: #212529; text-decoration: none; }
.app-dashboard-icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: none; border-radius: 10px; background: #e9f2ff; color: var(--app-primary); font-size: 1.4rem; }
.app-dashboard-copy { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.app-dashboard-copy strong { font-weight: 600; }
.app-dashboard-copy small { color: #6c757d; }
.app-dashboard-arrow { color: #9ca3af; font-size: 1.7rem; }
.app-welcome-card { padding: 28px; }
.app-welcome-card h2 { margin-bottom: 12px; font-size: 1.25rem; }
.app-welcome-card p { margin: 0; color: #6c757d; }

@media (max-width: 991.98px) {
    .app-sidebar { z-index: 1050; top: 0; left: -280px; width: 280px; padding: 0 16px 16px; transition: left .2s ease; }
    .app-sidebar.is-open { left: 0; }
    .app-sidebar-mobile-head { display: flex; align-items: center; justify-content: space-between; height: 64px; margin: 0 -16px 16px; padding: 0 16px; border-bottom: 1px solid #4b5563; color: #fff; font-size: 1.05rem; font-weight: 600; }
    .app-sidebar-close { background: transparent; color: #fff; }
    .app-sidebar-backdrop { position: fixed; z-index: 1040; inset: 0; background: rgba(15,23,42,.55); }
    .app-body.admin-menu-open { overflow: hidden; }
    .app-body.admin-menu-open .app-sidebar-backdrop { display: block; }
    .app-main { margin-left: 0; padding: calc(var(--app-header-height) + 20px) 16px 24px; }
    .app-header-inner { padding: 0 16px; }
}

@media (max-width: 575.98px) {
    .app-header-brand, .app-header-actions { gap: 9px; }
    .app-logo { font-size: 1rem; }
    .app-logo .app-brand-icon { width: 21px; height: 21px; }
    .app-user-name, .app-logout span { display: none; }
    .app-user .app-icon { font-size: 1.35rem; }
    .app-logout { width: 34px; height: 34px; padding: 0; justify-content: center; }
    .app-main { padding: calc(var(--app-header-height) + 20px) 12px 24px; }
    .app-content div[class$="-index"] > h1 { display: block; margin-bottom: 12px; }
    .app-content div[class$="-index"] > h1 + p { float: none; margin-bottom: 18px; }
    .app-content div[class$="-index"] > h1 + p .btn { width: 100%; }
    .app-page-heading { align-items: stretch; flex-direction: column; gap: 14px; }
    .app-page-heading .btn { width: 100%; }
    .contracts-filter-actions { width: 100%; }
    .contracts-filter-actions .btn { flex: 1; }
    .contracts-counter { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar { transition: none; }
}
