/* === Figurine Shop — admin styles === */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #2c2c2c;
    background: #f4f6f8;
}

a { color: #3563cc; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 16px; color: #444; }

/* === Layout (sidebar + content) === */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #1f2430;
    color: #d8dde6;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}
.brand {
    font-size: 18px; font-weight: 700; color: #fff;
    padding: 0 20px 20px; border-bottom: 1px solid #2d3344;
}
.sidebar nav { display: flex; flex-direction: column; padding: 12px 0; }
.sidebar nav a {
    color: #aab2c0;
    padding: 10px 20px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.sidebar nav a:hover { background: #2a3040; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #2a3040; color: #fff; border-left-color: #5b8dee; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid #2d3344;
    display: flex; flex-direction: column; gap: 10px;
}
.btn-new {
    background: #4caf50; color: #fff !important; padding: 8px 12px;
    border-radius: 6px; text-align: center; font-weight: 500;
}
.btn-new:hover { background: #43a047; text-decoration: none; }
.sidebar-footer .logout { color: #8a92a5; font-size: 13px; text-align: center; }

.content {
    flex: 1;
    padding: 24px 32px;
    max-width: 100%;
    overflow-x: auto;
}
.page-title { margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #e0e4ea; }

/* === Cards === */
.card {
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 18px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 1100px) { .grid-2col { grid-template-columns: 1fr; } }

/* === Stats grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    border-left: 4px solid #888;
    padding: 14px 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stat-label { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: #222; }
.stat-value span { font-size: 14px; font-weight: 400; color: #888; }

.stat-green  { border-color: #4caf50; }
.stat-orange { border-color: #ff9800; }
.stat-blue   { border-color: #5b8dee; }
.stat-purple { border-color: #9c27b0; }
.stat-teal   { border-color: #009688; }
.stat-red    { border-color: #e53935; }

/* === Forms === */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label,
label { display: block; font-size: 13px; color: #555; font-weight: 500; }
.form label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cdd2dc;
    border-radius: 5px;
    font: inherit;
    background: #fff;
    margin-top: 4px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #5b8dee;
    box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.12);
}
textarea { resize: vertical; }

button, .btn-secondary {
    cursor: pointer;
    padding: 8px 16px;
    background: #5b8dee;
    color: #fff;
    border: none;
    border-radius: 5px;
    font: inherit;
    font-weight: 500;
    transition: background .12s;
}
button:hover { background: #4574d6; }
.btn-secondary {
    background: #e6e9ef;
    color: #444;
    display: inline-block;
    text-decoration: none;
}
.btn-secondary:hover { background: #d8dce4; text-decoration: none; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.link-btn {
    background: none;
    border: none;
    padding: 2px 6px;
    color: #444;
    cursor: pointer;
    font-size: 16px;
}
.link-btn:hover { background: #f0f2f6; border-radius: 4px; }
.inline-form { display: inline; margin: 0; padding: 0; }

/* === Tables === */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.data-table th,
.data-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid #eef0f4;
    vertical-align: top;
}
.data-table th { font-weight: 600; color: #555; background: #f7f8fa; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.data-table tbody tr:nth-child(odd) { background: #fafbfc; }
.data-table tbody tr:hover { background: #f0f4fb; }
.data-table .right { text-align: right; }
.data-table .empty { text-align: center; padding: 24px; color: #888; font-style: italic; }
.data-table .actions { white-space: nowrap; }
.data-table .small { font-size: 11px; }
.data-table .row-muted { opacity: 0.55; }

.muted { color: #888; }
.muted.small, .small.muted, .small { font-size: 11px; color: #888; }

/* === Badges === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #fff;
}
.badge-green { background: #4caf50; }
.badge-grey  { background: #9aa0ac; }

.status-new         { background: #9aa0ac; }
.status-in_progress { background: #5b8dee; }
.status-ready       { background: #f1c40f; color: #4d3a00; }
.status-shipped     { background: #ff9800; }
.status-done        { background: #4caf50; }
.status-cancelled   { background: #e53935; }

.pay-unpaid  { background: #e53935; }
.pay-prepaid { background: #ff9800; }
.pay-paid    { background: #4caf50; }

/* === Filters === */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
    background: #fff;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #e0e4ea;
}
.filters select, .filters input { width: auto; min-width: 130px; margin-top: 0; }

/* === Login === */
body.login-page {
    background: #1f2430;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 10px;
    padding: 32px;
    width: 340px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.login-card h1 { text-align: center; }
.login-card p.muted { text-align: center; margin-bottom: 20px; }
.login-card label { margin-bottom: 12px; }
.login-card button { width: 100%; padding: 10px; font-size: 15px; margin-top: 8px; }
.error {
    background: #fde7e7; color: #b71c1c;
    padding: 10px 12px; border-radius: 5px; margin-bottom: 12px;
    border: 1px solid #f9c1c1;
    font-size: 13px;
}

/* === Flash === */
.flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid;
}
.flash-ok  { background: #e8f5e9; color: #2e7d32; border-color: #c5e1c8; }
.flash-err { background: #fde7e7; color: #b71c1c; border-color: #f9c1c1; }

/* === Order items table === */
.items-card { margin-top: 18px; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th, .items-table td { padding: 8px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.items-table th { font-size: 12px; color: #666; text-align: left; }
.items-table tfoot td { padding-top: 14px; border-bottom: none; }
.items-table .item-sum { text-align: right; font-variant-numeric: tabular-nums; }
.items-table .grand-total,
.items-table .grand-balance { text-align: right; font-size: 16px; }
.items-table .balance-row td { padding-top: 4px; }

/* Cell widths for orders.php list */
.orders-list .items-cell { max-width: 360px; font-size: 12px; color: #555; }

/* Footer note */
p.muted.small { margin: 8px 0; }

/* === Payment picker === */
.payment-badge { cursor: pointer; user-select: none; }
.payment-badge:hover { filter: brightness(0.92); }

.payment-picker {
    display: none;
    position: fixed;
    flex-direction: column;
    background: #fff;
    border: 1px solid #d9dde6;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.14);
    z-index: 1000;
    overflow: hidden;
    min-width: 150px;
}
.payment-picker.open { display: flex; }
.payment-picker button {
    padding: 8px 14px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: #2c2c2c;
    border-radius: 0;
}
.payment-picker button:hover { background: #f3f5f9; }

/* === Row click hover === */
.order-row { cursor: pointer; }

/* === Drawer === */
#drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(15,20,30,0.35);
    z-index: 190;
    display: none;
}
#drawer-overlay.open { display: block; }

.drawer {
    position: fixed;
    right: -460px; top: 0;
    width: 440px; max-width: 100vw;
    height: 100vh;
    background: #fff;
    box-shadow: -6px 0 24px rgba(0,0,0,0.14);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.18s ease;
    overflow: hidden;
}
.drawer.open { right: 0; }

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #ebeef3;
    background: #f8f9fb;
}
.drawer-header strong { font-size: 15px; }
.drawer-actions { display: flex; align-items: center; gap: 8px; }

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}
.detail-row {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed #eef0f4;
}
.detail-row label {
    width: 120px;
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    margin: 0;
}
.detail-row span { font-size: 13px; color: #222; }
.detail-row .preserve-lines { white-space: pre-wrap; }
.drawer-body hr {
    border: none; border-top: 1px solid #ebeef3; margin: 14px 0;
}

.drawer-items { width: 100%; border-collapse: collapse; margin-top: 8px; }
.drawer-items td { padding: 6px 4px; border-bottom: 1px solid #f0f2f6; font-size: 13px; vertical-align: middle; }
.drawer-items .thumb-cell { width: 44px; }
.drawer-items .drawer-total td { border-bottom: none; padding-top: 10px; font-size: 14px; }
.drawer-items .right { text-align: right; }

/* === Thumbnails === */
.thumb-cell img,
.thumb-cell .thumb-placeholder {
    width: 36px; height: 36px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
}
.thumb-cell .thumb-placeholder {
    background: #eef0f4;
    border: 1px dashed #d4d8e0;
}
.thumb-cell .thumb-48 { width: 48px; height: 48px; }
.products-list .thumb-cell { width: 64px; }
.products-list .thumb-cell img,
.products-list .thumb-cell .thumb-placeholder { width: 48px; height: 48px; }

/* === Tooltip for comments === */
.comment-preview {
    position: relative;
    cursor: default;
    font-size: 13px;
    color: #555;
}
.comment-preview::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #2c313d;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-wrap;
    max-width: 320px;
    width: max-content;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 70;
}
.comment-preview:hover::after { opacity: 1; }

/* === Deadline badge === */
.deadline-badge {
    font-size: 13px;
    color: #2c2c2c;
    white-space: nowrap;
}
.deadline-badge.overdue { color: #c0392b; font-weight: 600; }
.deadline-badge.soon    { color: #e67e22; font-weight: 600; }

/* === Order form thumbnail in items === */
.items-table .thumb-cell { width: 44px; }
.items-table .item-thumb {
    width: 36px; height: 36px;
    border-radius: 4px;
    object-fit: cover;
}
.items-table .thumb-placeholder {
    width: 36px; height: 36px;
    background: #eef0f4;
    border: 1px dashed #d4d8e0;
    border-radius: 4px;
}

/* === Image preview in product form === */
.image-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 6px 0 8px;
}
.image-preview img {
    width: 80px; height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e0e4ea;
}

/* === Delivery cell === */
.delivery-cell { font-size: 13px; color: #444; }

