/* ============================================================
   Admin Panel – CattleDirect Marketplace
   Reuses :root CSS variables from style.css
   ============================================================ */

/* ── Admin Body ── */
.admin-body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    min-height: 100vh;
}

/* ────────────────── LOGIN PAGE ────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--green-dark) 0%, var(--green-mid) 55%, var(--green-light) 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
    color: var(--white);
    padding: 32px 32px 28px;
    text-align: center;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-header p {
    font-size: .85rem;
    opacity: .8;
}

.login-body {
    padding: 32px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.login-field label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.login-field input {
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .95rem;
    color: var(--text-dark);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-field input:focus {
    outline: none;
    border-color: var(--green-mid);
    box-shadow: 0 0 0 3px rgba(45, 122, 79, .15);
    background: var(--white);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--green-mid), var(--green-dark));
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    transition: opacity var(--transition), transform var(--transition);
    letter-spacing: .3px;
}

.btn-login:hover:not(:disabled) {
    opacity: .92;
    transform: translateY(-1px);
}

.btn-login:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.login-alert {
    display: none;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    margin-top: 14px;
}

.login-alert.error {
    background: var(--red-pale);
    color: var(--red);
    border-left: 4px solid var(--red);
    display: flex;
}

.login-alert.success {
    background: var(--green-pale);
    color: var(--green-dark);
    border-left: 4px solid var(--green-mid);
    display: flex;
}

.login-footer-link {
    text-align: center;
    margin-top: 20px;
    font-size: .82rem;
    color: var(--text-light);
}

.login-footer-link a {
    color: var(--green-mid);
    font-weight: 600;
}

/* ────────────────── ADMIN DASHBOARD ────────────────── */
.admin-header {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
    color: var(--white);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.admin-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    max-width: 100%;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
}

.admin-brand span {
    font-size: 22px;
}

.admin-badge {
    background: var(--amber);
    color: var(--text-dark);
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .88rem;
}

.admin-user-chip {
    background: rgba(255, 255, 255, .15);
    border-radius: 50px;
    padding: 6px 14px;
    font-weight: 600;
}

.btn-logout {
    padding: 8px 18px;
    background: rgba(255, 255, 255, .12);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, .25);
}

/* Stats bar */
.admin-stats {
    display: flex;
    gap: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.admin-stat {
    flex: 1;
    padding: 18px 24px;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-stat:last-child {
    border-right: none;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.total {
    background: #e8f5ee;
}

.stat-icon.avail {
    background: #d1fae5;
}

.stat-icon.sold {
    background: #fee2e2;
}

.stat-icon.pending {
    background: #fef3c7;
}

.stat-text strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.stat-text span {
    font-size: .78rem;
    color: var(--text-mid);
    font-weight: 500;
}

/* Dashboard content */
.admin-content {
    padding: 28px 24px;
}

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-toolbar h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.admin-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-search {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .88rem;
    min-width: 220px;
    background: var(--white);
}

.admin-search:focus {
    outline: none;
    border-color: var(--green-mid);
}

/* Table */
.admin-table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.admin-table thead {
    background: var(--green-pale);
}

.admin-table th {
    padding: 13px 16px;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--green-dark);
    white-space: nowrap;
}

.admin-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
    font-size: .88rem;
}

.admin-table tbody tr:hover {
    background: var(--bg);
}

/* Thumbnail */
.cow-thumb {
    width: 52px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Status badge */
.status-badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 50px;
    font-size: .73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}

.status-badge.available {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.sold {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

/* Status select in table */
.status-select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    background: var(--white);
    cursor: pointer;
}

.status-select:focus {
    outline: none;
    border-color: var(--green-mid);
}

/* Action buttons */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    white-space: nowrap;
}

.btn-action:hover {
    opacity: .85;
    transform: translateY(-1px);
}

.btn-save {
    background: var(--green-light);
    color: var(--white);
}

.btn-delete {
    background: var(--red);
    color: var(--white);
}

/* Empty/loading */
.admin-state-row td {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

/* Confirm overlay */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(3px);
}

.confirm-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 360px;
    padding: 28px;
    text-align: center;
    animation: popIn .18s ease;
}

@keyframes popIn {
    from {
        transform: scale(.92);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.confirm-box .confirm-icon {
    font-size: 44px;
    margin-bottom: 10px;
}

.confirm-box h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-box p {
    font-size: .88rem;
    color: var(--text-mid);
    margin-bottom: 22px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-cancel-confirm {
    padding: 10px 22px;
    background: var(--bg);
    color: var(--text-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    font-size: .9rem;
}

.btn-confirm-delete {
    padding: 10px 22px;
    background: var(--red);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    font-size: .9rem;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
    color: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideUp .25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.success {
    background: var(--green-mid);
}

.toast.error {
    background: var(--red);
}

/* Responsive */
@media (max-width: 640px) {
    .admin-stats {
        flex-direction: column;
    }

    .admin-stat {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .admin-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-search {
        min-width: 100%;
    }
}