/* ===================================================
   BidPortal – Design System
   =================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --transition: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
}

/* ===== LAYOUT (Admin) ===== */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--gray-900);
    color: white;
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--gray-700);
    margin-bottom: 1rem;
}
.brand-icon { font-size: 1.75rem; }
.brand-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }

.nav-menu { display: flex; flex-direction: column; gap: .25rem; padding: 0 .75rem; }
.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1rem; border-radius: var(--radius);
    color: var(--gray-300); text-decoration: none;
    transition: background var(--transition), color var(--transition);
    font-size: .925rem;
}
.nav-link:hover { background: var(--gray-700); color: white; }
.nav-link.active { background: var(--primary); color: white; }
.nav-icon { font-size: 1.1rem; }

.main-content { flex: 1; display: flex; flex-direction: column; }

.topbar {
    background: white; padding: 1rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}
.page-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-700); }

.content-area { padding: 2rem; flex: 1; max-width: 1200px; }

/* ===== SHARED COMPONENTS ===== */

.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.header-actions { display: flex; gap: .5rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: var(--radius);
    font-size: .875rem; font-weight: 600; border: none;
    cursor: pointer; transition: all var(--transition);
    text-decoration: none; line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-600); }
.btn-outline:hover:not(:disabled) { background: var(--gray-100); }
.btn-sm { padding: .375rem .75rem; font-size: .8rem; }

/* Tables */
.table-container {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: var(--gray-50); padding: .875rem 1rem;
    text-align: left; font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}
.data-table td {
    padding: .875rem 1rem; border-bottom: 1px solid var(--gray-100);
    font-size: .875rem;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.row-closed { opacity: .6; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--danger); }
.price-cell { color: var(--primary); font-weight: 700; }
.actions { display: flex; gap: .375rem; }

/* Badges */
.badge {
    display: inline-block; padding: .25rem .75rem; border-radius: 9999px;
    font-size: .75rem; font-weight: 600;
}
.badge-active { background: var(--success-light); color: var(--success); }
.badge-closed { background: var(--gray-200); color: var(--gray-600); }

/* Forms */
.form-card {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow); padding: 2rem; max-width: 800px;
}
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block; font-size: .875rem; font-weight: 600;
    color: var(--gray-700); margin-bottom: .375rem;
}
.required { color: var(--danger); }
.form-control {
    width: 100%; padding: .625rem .875rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .925rem; transition: border-color var(--transition);
    background: white; color: var(--gray-800);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-hint { display: block; margin-top: .25rem; font-size: .8rem; color: var(--gray-400); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-fieldset {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.form-fieldset legend {
    font-size: .875rem; font-weight: 600; color: var(--gray-600);
    padding: 0 .5rem;
}
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--gray-200); }
.validation-summary { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }

/* Detail page */
.detail-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.info-card {
    background: white; padding: 1.25rem; border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.info-card.highlight { background: var(--primary); color: white; }
.info-card.highlight .info-label { color: rgba(255,255,255,.7); }
.info-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: .25rem; }
.info-value { font-size: 1.1rem; font-weight: 700; }
.price-large { font-size: 1.5rem; }
.description-box { background: white; padding: 1.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.description-box h3 { font-size: 1rem; color: var(--gray-600); margin-bottom: .5rem; }

.widget-embed-box {
    background: var(--gray-800); color: var(--gray-100); padding: 1.5rem;
    border-radius: var(--radius-lg); margin-bottom: 1.5rem;
}
.widget-embed-box h3 { font-size: 1rem; margin-bottom: .75rem; }
.code-block {
    display: block; background: var(--gray-900); padding: 1rem;
    border-radius: var(--radius); font-size: .8rem; overflow-x: auto;
    white-space: pre-wrap; word-break: break-all; color: #93c5fd;
}

/* Utility */
.loading, .empty-state { text-align: center; padding: 4rem 2rem; color: var(--gray-400); }
.alert { padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }

.spinner {
    display: inline-block; width: 1rem; height: 1rem;
    border: 2px solid rgba(255,255,255,.3); border-top-color: white;
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed; bottom: 2rem; right: 2rem;
    background: var(--gray-800); color: white;
    padding: .75rem 1.5rem; border-radius: var(--radius);
    font-size: .875rem; box-shadow: var(--shadow-lg);
    animation: fadeInUp .3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}


/* ===================================================
   BID WIDGET (iFrame)
   =================================================== */

.widget-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf7 100%);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 1.5rem;
}

.bid-widget {
    width: 100%; max-width: 520px;
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); overflow: hidden;
}

.widget-header {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white; padding: 1.5rem 1.5rem 1.25rem;
}
.widget-header h2 { font-size: 1.25rem; margin-bottom: .25rem; }
.widget-desc { font-size: .875rem; opacity: .85; }

.widget-price-area {
    display: flex; gap: 1rem; padding: 1.5rem;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.current-price-block, .buynow-block { flex: 1; text-align: center; }
.price-label {
    display: block; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .08em; color: var(--gray-500); margin-bottom: .25rem;
}
.price-value {
    display: block; font-size: 1.75rem; font-weight: 800;
    color: var(--gray-900); transition: color .3s ease;
}
.price-flash { color: var(--primary) !important; transform: scale(1.05); }
.buynow-price { color: var(--success); font-size: 1.25rem; }

.widget-info-row {
    display: flex; flex-wrap: wrap; gap: .5rem;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--gray-100);
}
.info-chip {
    background: var(--gray-100); padding: .375rem .75rem;
    border-radius: 9999px; font-size: .8rem; color: var(--gray-600);
}
.chip-label { font-weight: 600; margin-right: .25rem; }
.chip-urgent { background: #fef2f2; color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* Bid form */
.bid-form { padding: 1.5rem; }
.bid-form label { display: block; font-size: .875rem; font-weight: 600; color: var(--gray-700); margin-bottom: .5rem; }
.bid-input-row { display: flex; gap: .5rem; margin-bottom: .375rem; }
.bid-input {
    flex: 1; padding: .75rem 1rem; border: 2px solid var(--gray-300);
    border-radius: var(--radius); font-size: 1.1rem; font-weight: 700;
}
.bid-input:focus { outline: none; border-color: var(--primary); }
.bid-hint { font-size: .8rem; color: var(--gray-400); }

.btn-bid {
    background: var(--primary); color: white; padding: .75rem 1.5rem;
    border: none; border-radius: var(--radius); font-size: .925rem;
    font-weight: 700; cursor: pointer; transition: background var(--transition);
    white-space: nowrap;
}
.btn-bid:hover:not(:disabled) { background: var(--primary-hover); }
.btn-bid:disabled { opacity: .5; cursor: not-allowed; }

.btn-buynow {
    display: block; width: 100%; margin-top: .75rem;
    background: var(--success); color: white; padding: .75rem;
    border: none; border-radius: var(--radius); font-size: .925rem;
    font-weight: 700; cursor: pointer; transition: background var(--transition);
}
.btn-buynow:hover:not(:disabled) { background: #15803d; }

/* Status banners */
.bid-status {
    margin: 0 1.5rem 1.5rem; padding: 1rem;
    border-radius: var(--radius); font-size: .925rem; font-weight: 600; text-align: center;
}
.status-winning { background: var(--success-light); color: var(--success); }

.bid-feedback {
    margin: 0 1.5rem 1.5rem; padding: 1rem;
    border-radius: var(--radius); font-size: .875rem; text-align: center;
    animation: fadeInUp .3s ease;
}
.feedback-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.feedback-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.widget-closed-banner {
    text-align: center; padding: 2rem 1.5rem;
    background: var(--gray-50);
}
.widget-closed-banner h3 { font-size: 1.25rem; margin-bottom: .5rem; }

.widget-closed .widget-header {
    background: linear-gradient(135deg, var(--gray-600), var(--gray-700));
}

.widget-no-auth {
    padding: 1.5rem; text-align: center; color: var(--gray-500);
}
.widget-no-auth code {
    display: block; margin-top: .5rem; font-size: .8rem;
    background: var(--gray-100); padding: .5rem; border-radius: var(--radius);
}

.widget-error, .widget-loading {
    text-align: center; padding: 3rem; color: var(--gray-500);
}
.spinner-large {
    width: 2.5rem; height: 2.5rem; margin: 0 auto 1rem;
    border: 3px solid var(--gray-200); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 1rem 0; }
    .sidebar-brand { padding: 0 1rem .75rem; }
    .nav-menu { flex-direction: row; overflow-x: auto; padding: 0 .5rem; }
    .nav-link { white-space: nowrap; }
    .content-area { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .bid-input-row { flex-direction: column; }
    .widget-price-area { flex-direction: column; }
}
