/* ============================================================
   Inmate Lookup System - Stylesheet
   ============================================================ */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #2e53af;
    color: #334155;
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: #3651b5;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #283e8c;
    text-decoration: underline;
}

/* ---------- ACCESSIBILITY: FOCUS, SKIP LINK, SR-ONLY ---------- */
:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
    border-radius: 4px;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.btn-logout:focus-visible,
.back-link:focus-visible,
.sidebar-toggle:focus-visible,
.inmate-card-link:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 1px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #0f172a;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    font-weight: 700;
    text-decoration: none;
    z-index: 9999;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
    color: #ffffff;
    text-decoration: none;
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .btn-primary:hover {
        transform: none;
    }
    .inmate-card:hover {
        transform: none;
    }
}

/* ---------- AUTH PAGE LAYOUT ---------- */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: #4e73df;
}

/* ---------- CARD ---------- */
.card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    animation: fadeUp 0.4s ease;
}

.card.wide {
    max-width: 580px;
}

/* -- Split card: branding left, form right, all white -- */
.card.split {
    max-width: 780px;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    padding: 2.5rem 3rem;
}

.card-brand-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 220px;
    text-align: center;
    flex-shrink: 0;
}

.card-brand-side .brand {
    margin-bottom: 0;
}

.card-brand-side .brand-icon {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    margin-bottom: 1.25rem;
}

.card-brand-side .brand-icon img {
    width: 250px;
    height: 250px;
    object-fit: contain;
}

.card-form-side {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .card.split {
        flex-direction: column;
        padding: 2.5rem;
        gap: 1.5rem;
    }
    .card-brand-side {
        min-width: unset;
    }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- BRANDING ---------- */
.brand {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    margin-bottom: 1rem;
}

.brand-icon img {
    width: 250px;
    height: 250px;
    object-fit: contain;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

.brand p {
    font-size: 0.875rem;
    color: #64748b;
}

/* ---------- FORM ELEMENTS ---------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
    letter-spacing: 0.025em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus,
select:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.15);
    background: #ffffff;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.025em;
}

.btn-primary {
    background: linear-gradient(135deg, #4e73df, #4e73df);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(78, 115, 223, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(78, 115, 223, 0.45);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    box-shadow: none;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* ---------- MESSAGES ---------- */
.msg {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.msg-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.msg-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ---------- FOOTER LINKS ---------- */
.card-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

.card-footer a {
    font-weight: 600;
}

/* ============================================================
   DASHBOARD LAYOUT  (SB-Admin-style sidebar)
   ============================================================ */
.dashboard {
    display: flex;
    min-height: 100vh;
    background: #f0f2f5;
}

/* ---------- LEFT SIDEBAR ---------- */
.sidebar {
    width: 20%;
    max-width: 280px;
    min-width: 200px;
    min-height: 100vh;
    background: #4e73df;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-brand svg {
    width: 28px;
    height: 28px;
    min-width: 28px;
    max-width: 28px;
    flex-shrink: 0;
    fill: #d4a843;
    display: block;
}

/* -- Divider / section label -- */
.sidebar-heading {
    padding: 1.25rem 1.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
}

/* -- Nav links -- */
.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav li a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-nav li a.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-weight: 600;
}

.sidebar-nav li a svg {
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    flex-shrink: 0;
    fill: currentColor;
    opacity: 0.85;
    display: block;
}

/* -- Sidebar footer -- */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------- CONTENT WRAPPER (right of sidebar) ---------- */
.content-wrapper {
    flex: 1;
    margin-left: 20%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 1400px) {
    .content-wrapper { margin-left: 280px; }
}
@media (max-width: 1000px) {
    .content-wrapper { margin-left: 200px; }
}

/* ---------- TOP NAVBAR ---------- */
.topbar {
    background: #ffffff;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 56px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle {
    display: none;           /* shown on mobile */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    color: #475569;
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
    max-width: 22px;
    fill: currentColor;
    display: block;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.topbar-user {
    color: #64748b;
    font-size: 0.8125rem;
}

.topbar-user strong {
    color: #1e293b;
}

.btn-logout {
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    border: 1px solid #e2e8f0;
}

.btn-logout:hover {
    background: #e2e8f0;
    color: #1e293b;
    text-decoration: none;
}

/* ---------- MAIN CONTENT AREA ---------- */
.main-content {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* ---------- SIDEBAR OVERLAY (mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 190;
}

/* ---------- SEARCH SECTION ---------- */
.search-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.search-card h2 {
    font-size: 1.25rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.search-card p {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-form .form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.search-form .btn {
    width: auto;
    min-width: 140px;
    flex-shrink: 0;
}

.msg-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ---------- RESULTS ---------- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h3 {
    font-size: 1.125rem;
    color: #0f172a;
}

.results-count {
    font-size: 0.875rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-weight: 600;
}

/* ---------- INMATE CARDS ---------- */
.inmate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 1rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.inmate-grid > li {
    list-style: none;
}

.inmate-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #64748b;
    transition: transform 0.15s, box-shadow 0.15s;
}

.inmate-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.inmate-card.status-in-custody {
    border-left-color: #ef4444;
}

.inmate-card.status-released {
    border-left-color: #22c55e;
}

.inmate-card.status-transferred {
    border-left-color: #f59e0b;
}

.inmate-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.inmate-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
}

.inmate-id {
    font-size: 0.75rem;
    color: #475569;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.status-badge.in-custody {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.status-badge.released {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.status-badge.transferred {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.inmate-body {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "header header"
        "details mugshot";
    align-items: start;
    column-gap: 2rem;
}

.inmate-body > .detail-card-header { grid-area: header; }
.inmate-body > .inmate-details { grid-area: details; min-width: 0; }
.inmate-body > .mugshot-wrap { grid-area: mugshot; }

.mugshot-wrap {
    flex: 0 0 auto;
}

.mugshot {
    display: block;
    width: 180px;
    height: auto;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    object-fit: cover;
}

.inmate-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1.5rem;
}

.detail-item {
    font-size: 0.8125rem;
}

.detail-label {
    color: #475569;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
}

.detail-value {
    color: #1e293b;
    font-weight: 500;
}

/* ---------- CLICKABLE CARD LINK ---------- */
.inmate-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.inmate-card-link:hover {
    text-decoration: none;
    color: inherit;
}

.inmate-card-link .inmate-card {
    cursor: pointer;
}

/* ---------- BACK LINK ---------- */
.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #3651b5;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.back-link:hover {
    color: #283e8c;
    text-decoration: underline;
}

/* ---------- DETAIL CARD ---------- */
.detail-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border-left: 4px solid #64748b;
    margin-bottom: 1.5rem;
}

.detail-card-header h1,
.detail-card-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1.5rem;
}

/* ---------- CHARGES SECTION ---------- */
.charges-section {
    margin-top: 0;
    padding-top: 0;
}

.charges-section h2,
.charges-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.75rem;
}

.charges-list {
    list-style: none;
    padding: 0;
}

.charges-list li {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.charge-offense {
    font-weight: 600;
}

.charge-detail {
    font-size: 0.8125rem;
    color: #475569;
    margin-top: 0.25rem;
}

.charge-detail-label {
    font-weight: 600;
}

.charge-item {
    margin-bottom: 1rem;
}

.charge-item:last-child {
    margin-bottom: 0;
}

.charge-row,
.bond-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    align-items: flex-start;
    overflow-x: auto;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.bond-row {
    background: #f8fafc;
}

.charge-row > .detail-item,
.bond-row > .detail-item {
    flex: 1 1 0;
    min-width: 0;
}

.bonds-section {
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid #e2e8f0;
}

.bonds-section h3,
.bonds-section h4 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    margin: 0 0 0.4rem 0;
}

.bonds-section .bond-row + .bond-row {
    margin-top: 0.4rem;
}

.no-charges {
    font-size: 0.875rem;
    color: #475569;
}

/* ---------- NO RESULTS ---------- */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #475569;
}

.no-results svg {
    width: 64px;
    height: 64px;
    fill: #64748b;
    margin-bottom: 1rem;
}

.no-results h4 {
    font-size: 1.125rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.no-results p {
    font-size: 0.875rem;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .content-wrapper {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .topbar {
        padding: 0 1rem;
    }
    .topbar-user {
        display: none;
    }
    .search-form {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .search-form .form-group {
        flex: 1 1 0;
        min-width: 0;
    }
    .search-form .btn {
        flex: 0 0 100%;
        width: 100%;
    }
    .inmate-grid {
        grid-template-columns: 1fr;
    }
    .inmate-details {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.6rem 1rem;
    }
    .inmate-body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "mugshot"
            "header"
            "details";
        row-gap: 1rem;
    }
    .inmate-body > .mugshot-wrap {
        justify-self: center;
    }
    .inmate-body > .detail-card-header h1 {
        margin-bottom: 0;
    }
    .mugshot {
        width: 140px;
        margin: 0 auto;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .detail-card {
        padding: 1.25rem;
    }
    .detail-card-header h1,
    .detail-card-header h2 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    .charge-row,
    .bond-row {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 0.75rem 1rem;
        padding: 0.75rem;
    }
    .charge-row > .detail-item,
    .bond-row > .detail-item {
        flex: 1 1 calc(50% - 0.5rem);
    }
    .bonds-section {
        padding-left: 0.75rem;
    }
    .detail-value {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }
    .detail-card {
        padding: 1rem;
    }
    .charge-row > .detail-item,
    .bond-row > .detail-item {
        flex: 1 1 100%;
    }
    .inmate-details {
        gap: 0.5rem 1rem;
    }
}
