/* ========================================
   PenguinFlip — Dashboard Styles (Light)
   ======================================== */

:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #0369a1;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-heading: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --white: #ffffff;
    --success: #16a34a;
    --success-bg: rgba(22,163,74,0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220,38,38,0.08);
    --warning: #d97706;
    --warning-bg: rgba(217,119,6,0.08);
    --purple: #7c3aed;
    --purple-bg: rgba(124,58,237,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
    --sidebar-w: 260px;
    --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

/* === Login === */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0f9ff 100%);
}

.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 4px;
}
.login-logo-img {
    height: 100px;
    width: auto;
    display: inline-block;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.pin-greeting {
    text-align: center;
    color: var(--text);
    margin-bottom: 16px;
    font-size: 1.05rem;
}

.pin-input-group { text-align: center; }
.pin-input {
    width: 200px;
    text-align: center;
    font-size: 2rem;
    letter-spacing: 12px;
    padding: 12px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-heading);
    outline: none;
}
.pin-input:focus { border-color: var(--primary); }

.login-alt-link {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.login-footer {
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 24px;
}

/* === Layout === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.logo {
    display: flex;
    align-items: center;
}
.logo:hover { opacity: 0.85; }
.sidebar-logo-img {
    height: 42px;
    width: auto;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-muted);
    font-size: 0.93rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    color: var(--text-heading);
    background: var(--bg-hover);
}
.nav-item.active {
    color: var(--primary);
    background: rgba(14, 165, 233, 0.06);
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-icon { font-size: 1.15rem; width: 24px; text-align: center; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-heading);
    flex: 1;
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.user-name { font-size: 0.9rem; color: var(--text-muted); }

.page-content { padding: 24px; }

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
}
.card-body { padding: 20px; }
.chart-filters { display: flex; gap: 6px; }

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.stat-blue::before { background: var(--primary); }
.stat-green::before { background: var(--success); }
.stat-purple::before { background: var(--purple); }
.stat-orange::before { background: var(--accent); }
.stat-red::before { background: var(--danger); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.stat-detail {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 8px;
}

/* === Dashboard Grid === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* === Quick Stats === */
.quick-stats { padding: 4px 0; }
.qs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-light);
}
.qs-row:last-child { border-bottom: none; }
.qs-row span { color: var(--text-muted); font-size: 0.9rem; }
.qs-row strong { color: var(--text-heading); font-size: 0.95rem; }

/* === Tables === */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg);
}
.data-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .table-total-row { background: var(--bg); font-weight: 600; }

.product-cell { display: flex; flex-direction: column; gap: 2px; }
.product-link { color: var(--text-heading); font-weight: 600; }
.product-link:hover { color: var(--primary); }
.sku { font-size: 0.78rem; color: var(--text-light); font-family: monospace; }

.thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-xs);
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { font-size: 1.3rem; opacity: 0.3; }

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-new { background: var(--success-bg); color: var(--success); }
.badge-used { background: var(--warning-bg); color: var(--warning); }
.badge-reconditioned { background: var(--purple-bg); color: var(--purple); }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.status-draft { background: rgba(100,116,139,0.1); color: var(--text-muted); }
.status-listed { background: rgba(14,165,233,0.1); color: var(--primary); }
.status-sold { background: var(--success-bg); color: var(--success); }
.status-archived { background: rgba(100,116,139,0.08); color: var(--text-light); }
.status-returned { background: var(--danger-bg); color: var(--danger); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-xs);
    font-weight: 600;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; color: var(--white); }
.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-xs { padding: 4px 10px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-label .req { color: var(--danger); font-weight: 700; margin-left: 2px; }
.form-label small { font-weight: 400; }

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
.form-input::placeholder { color: var(--text-light); }

.form-textarea { resize: vertical; min-height: 80px; }

select.form-input { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-check { margin-top: 4px; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.sku-barcode-row {
    margin-bottom: 16px;
}
.sku-barcode-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: inline-block;
}
.sku-barcode-wrap svg {
    display: block;
    max-width: 280px;
    height: auto;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* === Toolbar === */
.barcode-lookup-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 16px;
}
.barcode-lookup-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.barcode-lookup-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}
.barcode-lookup-input {
    max-width: 340px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    letter-spacing: 1px;
}
.barcode-lookup-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.barcode-lookup-err {
    color: var(--danger);
    font-weight: 600;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; gap: 12px; align-items: center; }

.search-form { display: flex; gap: 8px; }
.search-input { width: 250px; }

.filter-bar { margin-bottom: 16px; }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select {
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}
.filter-select:focus { border-color: var(--primary); }
.filter-form-inline { display: flex; gap: 8px; align-items: center; }
.filter-form-inline .filter-group { flex-wrap: nowrap; }

/* === Bulk Actions === */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(14, 165, 233, 0.04);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}
.bulk-count { font-size: 0.85rem; color: var(--primary); font-weight: 600; }

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
}
.page-info { font-size: 0.85rem; color: var(--text-muted); }
.page-links { display: flex; gap: 4px; }

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 500;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.15); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(22,163,74,0.15); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(217,119,6,0.15); }

/* === Modals === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 300;
    display: none;
}
.modal-overlay.active { display: block; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 301;
    box-shadow: var(--shadow-lg);
    display: none;
    opacity: 0;
    transition: transform 0.2s, opacity 0.2s;
}
.modal.active { display: block; opacity: 1; transform: translate(-50%, -50%) scale(1); }

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-heading); }
.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* === Photos === */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.photo-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--bg);
    border: 1px solid var(--border);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-primary-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}
.photo-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.photo-item:hover .photo-actions { opacity: 1; }

.photo-upload {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 16px;
}
.upload-trigger:hover { color: var(--primary); }
.upload-icon { font-size: 2rem; }

/* === P&L / Accounting === */
.pnl-table { max-width: 700px; }
.pnl-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}
.pnl-section:last-child { border-bottom: none; }
.pnl-section h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.pnl-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
}
.pnl-row span { color: var(--text-muted); }
.pnl-total {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
}
.pnl-highlight { background: var(--bg); padding: 10px 12px; border-radius: var(--radius-xs); }
.pnl-final { font-size: 1.1rem; }

/* === Profit Preview === */
.profit-preview {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 12px;
}
.profit-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9rem;
}
.profit-row span { color: var(--text-muted); }

/* === Settings === */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.session-item:last-child { border-bottom: none; }
.session-info { display: flex; flex-direction: column; gap: 2px; }
.session-info strong { font-size: 0.85rem; color: var(--text); }
.session-info span { font-size: 0.78rem; color: var(--text-light); }

/* === Action Buttons === */
.action-buttons { display: flex; gap: 4px; }

/* === Text Utilities === */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-blue { color: var(--primary) !important; }
.text-center { text-align: center; }

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); color: var(--white); }
.toast-error { background: var(--danger); color: var(--white); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Responsive === */
@media (max-width: 1024px) {
    .form-grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-close { display: block; }
    .menu-toggle { display: block; }
    .main-content { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .page-content { padding: 16px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-right { flex-wrap: wrap; }
    .search-input { width: 100%; }
    .filter-group { flex-wrap: wrap; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr; }
    .form-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
