/* =====================================================================
   Denki Admin — Dashboard theme (same brand: Bookman Old Style)
   Colors: #1D4ED8 · #06B6D4 · #FFFFFF · #EFF6FF
   Text-only UI. Only icons: hamburger (menu) + close.
   ===================================================================== */

:root {
    --royal:  #1D4ED8;
    --royal-dk: #16409F;
    --cyan:   #06B6D4;
    --cyan-dk:#0891B2;
    --white:  #FFFFFF;
    --pale:   #EFF6FF;
    --ink:    #1E293B;
    --muted:  #64748B;
    --green:  #22A55B;
    --danger: #DC2626;
    --danger-dk: #B91C1C;
    --border: #DBEAFE;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(29, 78, 216, .10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Bookman Old Style', 'Bookman', Georgia, 'Times New Roman', serif;
    background: var(--pale); color: var(--ink); line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--royal); text-decoration: none; }
a:hover { color: var(--royal-dk); }

/* ---------------------------------------------------------------- Layout --- */

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

.sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--royal-dk); color: var(--white);
    display: flex; flex-direction: column;
    padding: 1.4rem 1rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.side-brand { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; margin: 0 .4rem 1.6rem; }
.side-brand img { height: 64px; width: auto; display: block; max-width: 100%; }
.side-brand-sub { font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: #7DE3F4; font-weight: 700; }

.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.side-nav a {
    display: block; padding: .68rem .95rem; border-radius: 8px;
    color: rgba(255,255,255,.92); font-weight: 700;
}
.side-nav a:hover { background: rgba(255,255,255,.12); color: var(--white); }
.side-nav a.active { background: var(--cyan); color: var(--white); }

.side-foot { margin-top: auto; padding-top: 1.2rem; border-top: 1px solid rgba(255,255,255,.16); }
.side-foot a { display: block; padding: .5rem 1rem; color: rgba(255,255,255,.9); border-radius: 8px; font-weight: 700; }
.side-foot a:hover { background: rgba(255,255,255,.12); color: var(--white); }

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

.topbar {
    background: var(--white); border-bottom: 1px solid var(--border);
    padding: .8rem 1.4rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: .8rem; }
.topbar h1 { font-size: 1.15rem; color: var(--ink); }
.topbar .who { color: var(--muted); font-size: .9rem; }
.topbar .who strong { color: var(--royal); }

.side-toggle { display: none; background: none; border: 1px solid var(--border);
               border-radius: 8px; padding: .42rem .65rem; cursor: pointer; }

.icon-menu { display: inline-block; width: 24px; }
.icon-menu span { display: block; height: 3px; width: 100%;
    background: var(--royal); border-radius: 2px; margin: 4.5px 0; }
.icon-close { display: inline-block; width: 22px; height: 22px; position: relative; }
.icon-close span { position: absolute; top: 50%; left: 0; width: 100%; height: 3px;
    background: var(--white); border-radius: 2px; transform: rotate(45deg); }
.icon-close span:last-child { transform: rotate(-45deg); }

.nav-close {
    display: none; background: var(--royal); border: none; border-radius: 50%;
    width: 42px; height: 42px; cursor: pointer; align-self: flex-end; margin-bottom: .5rem;
}

.content { padding: 1.6rem 1.4rem 2.6rem; }

/* -------------------------------------------------------------- Portable --- */

@media (max-width: 980px) {
    .sidebar {
        position: fixed; z-index: 1; right: 0; top: 0;
        height: 100vh; overflow-y: auto;
        opacity: 0; pointer-events: none;
        transition: opacity .2s ease;
        box-shadow: -10px 0 40px rgba(15,23,42,.25);
    }
    .sidebar.open { opacity: 1; pointer-events: auto; }
    .side-toggle { display: inline-block; text-decoration: none; }
    .nav-close { display: inline-block; }

    /* Pure-CSS fallback for the admin sidebar drawer */
    #adminNav:target { opacity: 1; pointer-events: auto; }
}
    .nav-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 70; }
}

/* ---------------------------------------------------------- Portlets/Cards --- */

.portlet {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow); margin-bottom: 1.6rem;
}
.portlet h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.portlet h2 .underline { display: block; width: 56px; height: 4px; border-radius: 2px;
    background: linear-gradient(90deg, var(--royal), var(--cyan)); margin-top: .35rem; }

.stat-grid {
    display: grid; gap: 1.1rem; margin-bottom: 1.8rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px)  { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem 1.35rem; box-shadow: var(--shadow);
    border-top: 4px solid var(--royal);
}
.stat-card.cyan { border-top-color: var(--cyan); }
.stat-card h3 { font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .3rem; }
.stat-card .num { font-size: 1.9rem; font-weight: 700; color: var(--royal); }
.stat-card.cyan .num { color: var(--cyan-dk); }
.stat-card .sub { font-size: .85rem; color: var(--muted); }

/* ---------------------------------------------------------------- Tables --- */

.table-wrap { overflow-x: auto; }
table.admin { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 560px; }
table.admin th {
    text-align: left; padding: .75rem .85rem;
    background: var(--pale); color: var(--royal-dk);
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
table.admin td { padding: .75rem .85rem; border-bottom: 1px solid #ECF2FE; vertical-align: middle; }
table.admin tr:hover td { background: #F8FBFF; }

.thumb {
    width: 62px; height: 46px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border); background: var(--pale);
}
.badge {
    display: inline-block; padding: .18rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 700;
    background: var(--pale); color: var(--royal); border: 1px solid var(--border);
}
.badge.admin { background: #ECFDF5; color: #166534; border-color: #A7F3D0; }
.badge.staff { background: #ECFEFF; color: #0E7490; border-color: #A5F3FC; }

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

.btn {
    display: inline-block; padding: .48rem 1rem; border-radius: 8px;
    border: 2px solid transparent; font-family: inherit; font-size: .95rem;
    font-weight: 700; cursor: pointer; text-align: center;
    transition: background .2s ease, color .2s ease, transform .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: .3rem .68rem; font-size: .85rem; border-radius: 6px; }

.btn-primary { background: var(--royal); color: var(--white); }
.btn-primary:hover { background: var(--royal-dk); color: var(--white); }
.btn-accent  { background: var(--cyan); color: var(--white); }
.btn-accent:hover { background: var(--cyan-dk); color: var(--white); }
.btn-ghost   { background: var(--white); color: var(--royal); border-color: var(--royal); }
.btn-ghost:hover { background: var(--pale); color: var(--royal-dk); }
.btn-danger  { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--danger-dk); color: var(--white); }
.btn-block { display: block; width: 100%; }

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

.form-grid { display: grid; gap: 1.05rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid.two { grid-template-columns: repeat(2, 1fr); } }

.field label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: .35rem; color: var(--royal-dk); }
.field input[type="text"], .field input[type="email"],
.field input[type="password"], .field input[type="number"],
.field select, .field textarea {
    width: 100%; padding: .7rem .95rem; font-family: inherit; font-size: 1rem;
    border: 1px solid #CBD5E1; border-radius: 8px; background: var(--white);
    color: var(--ink); outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--royal); box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.field small { display: block; color: var(--muted); margin-top: .3rem; }
.req { color: var(--danger); }

.preview img {
    margin-top: .5rem; width: 160px; height: 110px; object-fit: cover;
    border-radius: 10px; border: 1px solid var(--border);
}

/* ----------------------------------------------------------------- Misc --- */

.flash {
    padding: .8rem 1.2rem; border-radius: 10px; font-weight: 700; margin-bottom: 1.3rem;
}
.flash.success { background: #ECFDF5; color: #166534; border: 1px solid #A7F3D0; }
.flash.error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

.inline-form { display: inline; }

/* -------------------------------------------------------------- Unit form --- */
/* input + buttons side by side, perfectly aligned */

.unit-form {
    display: flex; align-items: stretch; gap: .75rem;
    max-width: 640px; flex-wrap: wrap;
}
.unit-field { flex: 1 1 300px; display: flex; flex-direction: column; }
.unit-field label { font-weight: 700; font-size: .88rem; margin-bottom: .4rem; color: var(--royal-dk); }
.unit-field input {
    width: 100%; height: 46px;
    padding: 0 1rem; font-family: inherit; font-size: 1rem;
    border: 1.5px solid #CBD5E1; border-radius: 10px;
    background: var(--white); color: var(--ink);
    outline: none;
}
.unit-field input:focus {
    border-color: var(--royal);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, .10);
}
.unit-actions { display: flex; align-items: flex-end; gap: .6rem; }
.unit-actions .btn { height: 46px; line-height: 1; display: inline-flex; align-items: center; padding: 0 1.5rem; box-sizing: border-box; }
.unit-actions .btn-ghost { padding: 0 1.2rem; }

/* ------------------------------------------------ Character hint row --- */
.unit-hint { max-width: 640px; color: var(--muted); font-size: .85rem; margin-top: -.4rem; }


/* ----------------------------------------------------------- Admin search --- */

.admin-search {
    flex: 1 1 300px;
    display: flex; align-items: center; gap: .55rem;
    background: var(--pale);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: .45rem .55rem .45rem 1.1rem;
    min-width: 280px;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.admin-search:focus-within {
    border-color: var(--royal);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, .10);
}
.admin-search input[type="search"] {
    flex: 1;
    border: none; outline: none; background: transparent;
    font-family: inherit; font-size: 1rem;
    padding: .55rem .25rem; color: var(--ink);
    min-width: 0;
}
.admin-search input[type="search"]::placeholder { color: #93A8D0; font-style: italic; }
.admin-search .btn { flex-shrink: 0; }

/* --------------------------------------------------------------- Login --- */

.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(130deg, var(--royal-dk), var(--royal) 55%, var(--cyan-dk));
    padding: 1.4rem;
}
.login-card {
    background: var(--white); border-radius: 14px; padding: 2.4rem 2.2rem;
    width: min(430px, 100%); box-shadow: 0 24px 70px rgba(10, 20, 60, .35);
}
.login-card .login-logo, .login-logo {
    height: 118px; width: auto; display: block; margin: 0 auto .3rem; max-width: 100%;
}
.login-card .sub { color: var(--muted); font-size: .88rem; margin-bottom: 1.6rem; }
.login-actions { margin-top: 1.4rem; display: flex; justify-content: space-between; align-items: center; }
