/* =========================================================
   product_manager styles
   Mobile-first, then enhanced for larger screens.
========================================================= */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: #f4f7fb;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
}

.wrapper {
    max-width: 1250px;
    margin: 0 auto;
    padding: 12px 12px 90px;
}

.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    margin-bottom: 20px;
}

/* ---------------- Header ---------------- */
.header {
    padding: 18px 16px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.header h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.header p {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: .95;
}

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.logout-btn {
    display: inline-block;
    padding: 10px 14px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.25);
    white-space: nowrap;
}

.logout-btn:active {
    background: rgba(255,255,255,0.3);
}

.content {
    padding: 16px;
}

/* ---------------- Alerts ---------------- */
.alert {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}

.success {
    background: #e8f8ee;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* ---------------- Form ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.full {
    grid-column: 1 / -1;
}

label {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

input,select , textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 13px 14px;
    /* 16px stops iOS Safari auto-zoom on focus */
    font-size: 16px;
    outline: none;
    background: #fff;
    font-family: inherit;
}

input:focus, textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* File input styled as a big tappable button on mobile */
input[type="file"] {
    padding: 12px;
    font-size: 14px;
    background: #f9fafb;
    border: 1.5px dashed #c7d2fe;
    cursor: pointer;
}

.file-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

/* Live thumbnail preview of images chosen on the phone, before upload */
.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.image-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn {
    border: none;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    flex: 1 1 auto;
    text-align: center;
    min-height: 48px; /* comfortable tap target */
}

.btn-add { background: #16a34a; color: #fff; }
.btn-add:active { background: #15803d; }

.btn-update { background: #d97706; color: #fff; }
.btn-update:active { background: #b45309; }

.btn-cancel {
    background: #e5e7eb;
    color: #111827;
}
.btn-cancel:active { background: #d1d5db; }

.btn-login {
    background: #2563eb;
    color: #fff;
    width: 100%;
}
.btn-login:active {
    background: #1d4ed8;
}

.section-title {
    margin: 22px 4px 12px;
    font-size: 19px;
}

/* ---------------- Product list: table on desktop ---------------- */
.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15,23,42,0.06);
    border: 1px solid #e5e7eb;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

thead {
    background: #eff6ff;
}

th, td {
    padding: 14px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: #1e3a8a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

tr:hover { background: #fafcff; }

.price {
    font-weight: 700;
    color: #047857;
}

.images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.images img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    min-height: 40px;
}

.edit-btn {
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.edit-btn:active { background: #1d4ed8; }

.delete-btn {
    background: #dc2626;
    color: #fff;
}
.delete-btn:active { background: #b91c1c; }

.muted {
    color: #6b7280;
    font-size: 12px;
    margin-top: 6px;
}

.empty {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

a.product-link {
    color: #2563eb;
    text-decoration: none;
    word-break: break-all;
}
a.product-link:hover { text-decoration: underline; }

.existing-images { margin-top: 10px; }

.login-wrap {
    max-width: 460px;
    margin: 40px auto;
}

.welcome-badge {
    font-size: 12px;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
}

.cat-badge {
    display: inline-block;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #e0e7ff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

/* ---------------- Mobile card list (replaces table under 760px) ---------------- */
@media (max-width: 760px) {
    .table-wrap {
        overflow: visible;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    table, thead, tbody, th { display: none; } /* hide the tabular header entirely */

    table { min-width: 0; width: 100%; }

    tbody { display: block; }

    tr {
        display: block;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        box-shadow: 0 6px 16px rgba(15,23,42,0.05);
        margin-bottom: 14px;
        padding: 6px 4px;
    }

    tr:hover { background: #fff; }

    td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 12px;
        border-bottom: 1px dashed #eef0f3;
        font-size: 14px;
        text-align: right;
    }

    td:last-child { border-bottom: none; }

    /* Label injected via data-label, shown on the left */
    td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #6b7280;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .3px;
        text-align: left;
        flex: 0 0 38%;
    }

    td[data-label="Product Name"] {
        font-size: 16px;
        font-weight: 800;
        color: #111827;
    }

    .images, .actions {
        justify-content: flex-end;
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn-sm,
    .actions form {
        width: 100%;
    }

    .actions .edit-btn,
    .actions .delete-btn {
        width: 100%;
    }
}

/* ---------------- General responsive breakpoints ---------------- */
@media (min-width: 620px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .btn { flex: 0 1 auto; }
    .btn-login { width: auto; }
}

@media (min-width: 700px) {
    .wrapper { padding: 30px 15px; }
    .header { padding: 22px 24px; position: static; }
    .header h1 { font-size: 28px; }
    .header p { font-size: 14px; }
    .content { padding: 24px; }
    .section-title { font-size: 22px; margin: 28px 0 14px; }
}