/* Portal & Admin shared styles */

/* ── Layout ──────────────────────────────────────────────────────────────── */

.portal-body,
.admin-body {
    background: var(--soft);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-main,
.admin-main {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px clamp(16px, 4vw, 40px) 60px;
}

/* ── Portal header ───────────────────────────────────────────────────────── */

.portal-header,
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(16px, 4vw, 40px);
    background: var(--deep);
    color: #fff;
}

.portal-header .brand,
.admin-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.portal-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.portal-user-name {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.portal-user-name .muted {
    color: rgba(255, 255, 255, 0.5);
}

.portal-signout,
.admin-signout {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
}

.portal-signout:hover,
.admin-signout:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.7);
}

/* ── Admin nav ───────────────────────────────────────────────────────────── */

.admin-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-nav a {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.75);
}

.admin-nav a:hover,
.admin-nav a[aria-current='page'] {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.admin-nav .admin-signout {
    margin-left: 12px;
}

/* ── Portal footer ───────────────────────────────────────────────────────── */

.portal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 20px;
    font-size: 13px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    background: var(--paper);
}

.portal-footer a {
    color: var(--muted);
}

.portal-footer a:hover {
    color: var(--ink);
}

/* ── Login box ───────────────────────────────────────────────────────────── */

.login-wrap {
    display: flex;
    justify-content: center;
    padding-top: 40px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 36px 32px;
}

.login-box h1 {
    font-size: 22px;
    margin-bottom: 24px;
    line-height: 1.3;
}

.login-box label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}

.login-box input {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
    width: 100%;
}

.login-box input:focus {
    outline: 2px solid var(--deep);
    outline-offset: 1px;
    border-color: transparent;
}

.login-box .button {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

/* ── Flash message ───────────────────────────────────────────────────────── */

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}

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

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

/* ── Page heading ────────────────────────────────────────────────────────── */

.page-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-heading h1 {
    font-size: clamp(22px, 3vw, 30px);
    margin: 0;
}

/* ── Data table ──────────────────────────────────────────────────────────── */

.data-table-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--soft);
    border-bottom: 1px solid var(--line);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

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

.data-table tr:hover td {
    background: var(--soft);
}

.data-table .col-id     { width: 70px; }
.data-table .col-status { width: 140px; }
.data-table .col-date   { width: 120px; white-space: nowrap; }
.data-table .col-action { width: 100px; text-align: right; }

.empty-row td {
    text-align: center;
    color: var(--muted);
    padding: 40px 16px;
}

/* ── Status badge ────────────────────────────────────────────────────────── */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-received  { background: #e0f2fe; color: #0369a1; }
.status-diagnosing{ background: #fef9c3; color: #854d0e; }
.status-in_repair { background: #fef3c7; color: #92400e; }
.status-ready     { background: #dcfce7; color: #166534; }
.status-shipped   { background: #f3e8ff; color: #6b21a8; }

/* ── Detail card ─────────────────────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 24px;
}

.detail-card h2 {
    font-size: 15px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 14px;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 15px;
    color: var(--ink);
}

.detail-value.big {
    font-size: 22px;
    font-weight: 700;
}

/* ── Notes ───────────────────────────────────────────────────────────────── */

.notes-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-item {
    background: var(--soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
}

.note-item p {
    margin: 0 0 4px;
    font-size: 14px;
    line-height: 1.5;
}

.note-date {
    font-size: 12px;
    color: var(--muted);
}

/* ── Forms (admin) ───────────────────────────────────────────────────────── */

.form-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 680px;
}

.form-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}

.form-card input,
.form-card select,
.form-card textarea {
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
    width: 100%;
}

.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
    outline: 2px solid var(--deep);
    outline-offset: 1px;
    border-color: transparent;
}

.form-card textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    margin-top: 3px;
}

/* ── Inline note form ────────────────────────────────────────────────────── */

.note-form {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-top: 16px;
}

.note-form textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 12px;
}

.note-visibility {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
}

/* ── Admin stat strip ────────────────────────────────────────────────────── */

.stat-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-tile {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.stat-tile:hover,
.stat-tile.active {
    border-color: var(--deep);
}

.stat-tile strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-tile span {
    font-size: 12px;
    color: var(--muted);
}

/* ── Buttons (portal context) ────────────────────────────────────────────── */

.link-btn {
    font-size: 13px;
    font-weight: 700;
    color: var(--deep);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-btn:hover {
    color: var(--ink);
}

.back-link-plain {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 20px;
}

.back-link-plain:hover {
    color: var(--ink);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stat-strip {
        grid-template-columns: repeat(3, 1fr);
    }

    .data-table .col-date,
    .data-table .hide-mobile {
        display: none;
    }

    .login-box {
        padding: 24px 20px;
    }
}
