/* =========================================================
   Apogee Admin — Panel Styles
   ========================================================= */

.admin-body {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    background: var(--bg);
    margin: 0;
}

/* ----- Sidebar ----- */
.admin-sidebar {
    background: var(--bg-darker);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text);
}

.admin-sidebar__brand img {
    height: 32px;
    width: auto;
}

.admin-sidebar__nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 0.75rem;
}

.admin-sidebar__nav a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.admin-sidebar__nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.admin-sidebar__nav a.is-active {
    background: var(--surface);
    color: var(--accent);
}

.admin-sidebar__footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

.admin-sidebar__footer a {
    color: var(--text-muted);
    transition: color var(--transition);
}

.admin-sidebar__footer a:hover {
    color: var(--accent);
}

/* ----- Main ----- */
.admin-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-dark);
}

.admin-header h1 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    margin: 0;
}

.admin-header__user {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-header__user strong {
    color: var(--text);
}

.admin-content {
    padding: 2rem 2.5rem;
    max-width: none;
}

/* ----- Alerts ----- */
.admin-alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.admin-alert--success {
    background: rgba(194, 222, 24, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
}

.admin-alert--error {
    background: rgba(200, 30, 30, 0.15);
    border: 1px solid #c81e1e;
    color: #ff8888;
}

/* ----- Toolbar ----- */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-search {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 500px;
}

.admin-search input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
}

.admin-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.admin-search .btn {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
}

.admin-clear {
    align-self: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.admin-toolbar__count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ----- Table ----- */
.admin-table-wrap {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table thead {
    background: var(--bg-darker);
}

.admin-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: var(--bg-darker);
}

.admin-table a {
    color: var(--accent);
}

.admin-table__date {
    white-space: nowrap;
    color: var(--text-muted) !important;
}

.admin-link {
    font-weight: 500;
    white-space: nowrap;
}

/* ----- Badges ----- */
.admin-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-muted);
}

.admin-badge--urgent {
    background: rgba(200, 30, 30, 0.2);
    color: #ff8888;
}

.admin-badge--file {
    background: rgba(194, 222, 24, 0.15);
    color: var(--accent);
}

.admin-badge--lg {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.admin-muted {
    color: var(--text-dim);
}

/* ----- Empty state ----- */
.admin-empty {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-dark);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

/* ----- Pagination ----- */
.admin-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-pagination a {
    color: var(--accent);
    font-weight: 500;
}

/* ----- Detail page ----- */
.admin-back {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-back:hover {
    color: var(--accent);
}

.admin-detail {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 800px;
}

.admin-detail__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.admin-detail__header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.admin-detail__list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.85rem 1.5rem;
    margin: 0 0 2rem;
}

.admin-detail__list dt {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 0.15rem;
}

.admin-detail__list dd {
    margin: 0;
    color: var(--text);
}

.admin-detail__details {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    line-height: 1.6;
}

.admin-detail__actions {
    display: flex;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.btn--danger {
    background: #c81e1e;
    color: white;
}

.btn--danger:hover {
    background: #a51818;
}

/* ----- Login page ----- */
.admin-login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-darker);
    background-image:
        linear-gradient(135deg, rgba(28, 28, 31, 0.9), rgba(48, 48, 51, 0.95)),
        url('/assets/images/AG_bg.jpg');
    background-size: cover;
    background-position: center;
}

.admin-login {
    width: 100%;
    max-width: 400px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.admin-login__logo {
    text-align: center;
    margin-bottom: 1rem;
}

.admin-login__logo img {
    height: 56px;
    width: auto;
    margin: 0 auto;
}

.admin-login h1 {
    text-align: center;
    font-size: 1.35rem;
    margin-bottom: 1.5rem;
}

.admin-login__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-login__form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.admin-login__form input {
    width: 100%;
    padding: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
}

.admin-login__form input:focus {
    outline: none;
    border-color: var(--accent);
}

.admin-login__form .btn {
    margin-top: 0.5rem;
    width: 100%;
}

.admin-login__back {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.admin-login__back:hover {
    color: var(--accent);
}

/* ----- Hamburger button (hidden on desktop) ----- */
.admin-hamburger {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 300;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.admin-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.admin-hamburger.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.admin-hamburger.is-open span:nth-child(2) {
    opacity: 0;
}
.admin-hamburger.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ----- Backdrop ----- */
.admin-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.admin-sidebar-backdrop.is-visible {
    opacity: 1;
}

/* ----- Mobile / tablet ----- */
@media (max-width: 900px) {
    .admin-hamburger {
        display: flex;
    }

    .admin-body {
        grid-template-columns: 1fr;
    }

    /* Sidebar slides in from the left as an off-canvas drawer */
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        height: 100vh;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    /* Push main content right to make room for the fixed hamburger button */
    .admin-main {
        padding-top: 0;
    }

    .admin-header {
        padding: 1.25rem 1.25rem 1.25rem 4.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        min-height: 64px; /* Ensures the header is tall enough for the button */
        justify-content: center;
    }

    .admin-header h1 {
        font-size: 1.15rem;
    }

    .admin-content {
        padding: 1.25rem;
    }

    /* Prevent page scroll while the drawer is open */
    body.admin-nav-open {
        overflow: hidden;
    }

    /* Detail page responsiveness */
    .admin-detail__list {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .admin-detail__list dt {
        padding-top: 0.75rem;
    }
    .admin-detail {
        padding: 1.5rem;
    }
    .admin-detail__header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Table: allow horizontal scroll on narrow screens rather than cram */
    .admin-table-wrap {
        overflow-x: auto;
    }
    .admin-table {
        font-size: 0.85rem;
        min-width: 700px;
    }
    .admin-table th,
    .admin-table td {
        padding: 0.65rem 0.75rem;
        white-space: nowrap;
    }

    /* Toolbar stacks */
    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-search {
        max-width: 100%;
    }

    /* Tools grid: single column */
    .admin-tools-grid {
        grid-template-columns: 1fr;
    }

    /* Login page tweak */
    .admin-login {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }
}

/* Small phone refinements */
@media (max-width: 500px) {
    .admin-hamburger {
        top: 0.85rem;
        left: 1rem;
        width: 38px;
        height: 38px;
    }
    .admin-header {
        padding-left: 4rem;
    }
    .admin-content {
        padding: 1rem;
    }
    .admin-sidebar {
        width: 240px;
    }
}
   

    /* ----- Tools grid ----- */
.admin-tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
}

/* Tablet: 2 across */
@media (max-width: 1024px) {
    .admin-tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 stacked */
@media (max-width: 768px) {
    .admin-tools-grid {
        grid-template-columns: 1fr;
    }
}

.admin-tool-card {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    transition: border-color var(--transition), transform var(--transition);
}

.admin-tool-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.admin-tool-card__icon {
    font-size: 1.75rem;
    line-height: 1;
    flex-shrink: 0;
}

.admin-tool-card__body h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin: 0 0 0.35rem;
}

.admin-tool-card__body p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

.admin-tool-card__stat {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    background: rgba(194, 222, 24, 0.15);
    color: var(--accent);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ----- Password strength checklist ----- */
.pw-checklist {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    display: grid;
    gap: 0.2rem;
}

.pw-checklist > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dim);
    transition: color 0.15s;
}

.pw-checklist > div.is-ok {
    color: var(--accent);
}

.pw-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}

.pw-checklist > div.is-ok .pw-dot {
    background: var(--accent);
}

.pw-match {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    min-height: 1.1rem;
}

.pw-match.is-ok { color: var(--accent); }
.pw-match.is-bad { color: #ff8888; }

.admin-login__forgot {
    display: block;
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--accent);
}

.admin-login__forgot:hover {
    color: var(--accent-hover);
}

/* =========================================================
   Mobile-Friendly Tables
   ========================================================= */

@media (max-width: 768px) {
    /* Transform tables into card-style blocks */
    .admin-table-wrap {
        border: none;
        background: transparent;
        overflow: visible;
    }

    .admin-table {
        min-width: 0;
        display: block;
    }

    .admin-table thead {
        display: none; /* Hide table headers on mobile */
    }

    .admin-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .admin-table tr {
        display: block;
        background: var(--bg-darker); /* Matches option groups */
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 1rem 1.25rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Slight depth */
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border); /* Keep the divider */
        white-space: normal;
        text-align: right;
        font-size: 0.9rem;
    }

    /* Action row at the bottom of the card */
    .admin-table td:last-child {
        border-bottom: none;
        padding-top: 0.85rem;
        padding-bottom: 0;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border);
        justify-content: flex-end;
        gap: 1rem;
    }

    /* Use data-label attributes for the mobile "headers" */
    .admin-table td::before {
        content: attr(data-label);
        font-family: var(--font-heading);
        font-size: 0.7rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--text-dim);
        margin-right: 1rem;
        text-align: left;
        flex-shrink: 0;
        opacity: 0.7;
    }

    /* Adjustments for the specific action column */
    .admin-table td:last-child::before {
        display: none;
    }
    
    /* Make the Product Name look like a card title */
    .admin-table td:first-child {
        font-family: var(--font-heading);
        font-size: 1.15rem;
        font-weight: 600;
        color: var(--text);
        padding-top: 0;
        padding-bottom: 0.85rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--accent);
        justify-content: flex-start;
        text-align: left;
    }
    
    .admin-table td:first-child::before {
        display: none; /* The name is the title, no label needed */
    }
}

/* =========================================================
   Submissions List (Card Layout)
   ========================================================= */

.admin-submissions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-submission-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.admin-submission-card:hover {
    border-color: var(--accent);
    background: var(--bg-darker);
    transform: translateY(-2px);
}

.admin-submission-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.admin-submission-card__title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.admin-submission-card__title strong {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text);
}

.admin-submission-card__date {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.admin-submission-card__badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-submission-card__total {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.5rem;
}

.admin-submission-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.admin-submission-card__row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
    font-size: 0.9rem;
}

.admin-submission-card__label {
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-top: 0.15rem;
}

.admin-submission-card__value {
    color: var(--text-muted);
    word-break: break-word;
}

.admin-submission-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.admin-submission-card__file {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.admin-submission-card .admin-link {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    margin-left: auto; /* Pushes the link to the far right */
}

/* Responsive adjustments for tablets */
@media (max-width: 900px) {
    .admin-submission-card__row {
        grid-template-columns: 1fr;
        gap: 0.1rem;
        margin-bottom: 0.5rem;
    }
    .admin-submission-card__label {
        padding-top: 0;
    }
}

/* ----- Styled admin select ----- */
.admin-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    height: 48px;
    padding: 0 2.5rem 0 0.85rem;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path fill='none' stroke='%23C2DE18' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 14px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.admin-select:hover {
    border-color: var(--border-strong);
    background-color: var(--surface-hover);
}

.admin-select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--surface);
}

.admin-select option {
    background: var(--bg-dark);
    color: var(--text);
    padding: 0.75rem;
    font-family: var(--font-body);
    font-weight: 400;
}

.admin-select optgroup {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--accent);
    background: var(--bg-darker);
}

/* ----- Analytics Dashboard ----- */
.analytics-grid-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .analytics-grid-tables {
        grid-template-columns: 1fr;
    }
}
}
