/* ============================================================
   Tienda de Videojuegos - Estilos finales unificados
   ============================================================ */

/* ---------- Reset & root ---------- */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg-page:      #0f1419;
    --bg-surface:   #1a2230;
    --bg-elevated:  #232d3f;
    --border:       #2d3a4f;
    --text:         #e6edf3;
    --text-muted:   #8b95a5;
    --accent:       #4f9eff;
    --accent-hover: #6ab2ff;
    --success:      #3fb950;
    --warning:      #d29922;
    --danger:       #f85149;
    --shadow:       0 4px 16px rgba(0,0,0,0.35);
    --radius:       8px;
    --radius-sm:    4px;
    --transition:   0.2s ease;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-page);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
    margin: 0 0 0.6em;
    font-weight: 600;
    line-height: 1.25;
}
h1 { font-size: 1.8em; }
h2 { font-size: 1.35em; }
h3 { font-size: 1.05em; }

hr { border: none; border-top: 1px solid var(--border); margin: 25px 0; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar a { color: var(--text); }
.topbar a:hover { color: var(--accent); }
.topbar .brand {
    font-weight: 700;
    font-size: 1.15em;
    color: var(--accent);
    margin-right: 24px;
}
.topbar nav a { margin-right: 18px; }
.topbar .user-info { font-size: 0.9em; color: var(--text-muted); }
.topbar .user-info strong { color: var(--text); }

/* ---------- Layout ---------- */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px;
}

.section-title {
    font-size: 1.4em;
    margin: 32px 0 18px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

/* ---------- Cards (boxes) for forms / dashboards ---------- */
.box {
    max-width: 520px;
    margin: 40px auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.35s ease;
}
.box.box-wide { max-width: 900px; }
.box.box-xwide { max-width: 1100px; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Forms ---------- */
label {
    display: block;
    margin: 14px 0 6px;
    font-size: 0.9em;
    color: var(--text-muted);
    font-weight: 500;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95em;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 158, 255, 0.18);
}
input[type="checkbox"] { width: auto; margin-right: 6px; }
small {
    display: block;
    color: var(--text-muted);
    font-size: 0.82em;
    margin-top: 4px;
}

button, .btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform 0.1s;
    margin-top: 12px;
}
button:hover, .btn:hover {
    background: var(--accent-hover);
    color: #fff;
}
button:active, .btn:active { transform: translateY(1px); }
button.btn-secondary, .btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
button.btn-secondary:hover, .btn-secondary:hover {
    background: var(--bg-elevated);
    color: var(--text);
}
button.btn-danger, .btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}
button.btn-danger:hover, .btn-danger:hover { background: #ff6359; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 16px 0;
}
fieldset legend {
    color: var(--text-muted);
    font-size: 0.85em;
    padding: 0 8px;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ffb8b3;
}
.alert.ok {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.4);
    color: #9be9a8;
}
.alert ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
table th, table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92em;
}
table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.04em;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: rgba(79, 158, 255, 0.04); }

/* ---------- Filters bar ---------- */
.filters {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}
.filters label { margin: 0 6px 0 0; }
.filters input[type="text"],
.filters select {
    width: auto;
    min-width: 180px;
    flex: 0 1 220px;
}
.filters .results-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.88em;
}

/* ---------- Product grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
    opacity: 0;
    animation: cardIn 0.45s ease forwards;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
    color: var(--text);
}
.card .img-placeholder {
    background: var(--bg-elevated);
    aspect-ratio: 16 / 10;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85em;
    overflow: hidden;
    position: relative;
}
.card .img-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.card h3 { margin: 0 0 6px; font-size: 1em; }
.card .desc {
    font-size: 0.85em;
    color: var(--text-muted);
    margin: 0 0 12px;
    flex-grow: 1;
}
.card .price {
    font-weight: 700;
    color: var(--accent);
    font-size: 1.1em;
}
.card .stock {
    font-size: 0.8em;
    color: var(--success);
    margin-top: 4px;
}
.card .stock.low      { color: var(--warning); }
.card .stock.out      { color: var(--danger); }
.card .badge-destacado {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--warning);
    color: #1a1a1a;
    font-size: 0.7em;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    z-index: 1;
}
.card .meta-cat {
    font-size: 0.78em;
    color: var(--text-muted);
    margin-top: 6px;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.empty {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- Detail page ---------- */
.detalle {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 28px;
}
.detalle .img-big {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    overflow: hidden;
}
.detalle .img-big img {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
}
.detalle h1 { margin: 0 0 12px; font-size: 1.7em; }
.detalle .price-big {
    font-size: 1.8em;
    color: var(--accent);
    font-weight: 700;
    margin: 12px 0;
}
.detalle table { background: transparent; }
.detalle table td { border-bottom: 1px solid var(--border); }
.detalle table td:first-child {
    width: 40%;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: none;
    background: transparent;
    font-size: 0.92em;
    letter-spacing: normal;
}

.review {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 10px;
}

/* ---------- Toast notifications ---------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--bg-elevated);
    color: var(--text);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
    min-width: 240px;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    font-size: 0.92em;
}
.toast.ok    { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ---------- Badges ---------- */
.user-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
}
.badge-admin   { background: var(--warning); color: #1a1a1a; }
.badge-cliente { background: var(--success); color: #0f1f12; }

/* ---------- Stat list (dashboards) ---------- */
.stats {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.stats li {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}
.stats li strong {
    display: block;
    font-size: 1.6em;
    color: var(--accent);
    margin-top: 4px;
}

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, #1a2238 0%, #2d1b4f 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    margin-bottom: 24px;
    text-align: center;
}
.hero h1 { font-size: 2.2em; margin-bottom: 10px; }
.hero p { color: var(--text-muted); font-size: 1.05em; margin-bottom: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
    }
    .topbar .brand { margin-right: 0; }
    .topbar nav a { margin-right: 12px; }
    .container { padding: 16px 14px; }
    .box { margin: 20px auto; padding: 22px 20px; }
    .detalle { grid-template-columns: 1fr; padding: 20px; }
    .filters { flex-direction: column; align-items: stretch; }
    .filters input[type="text"], .filters select { width: 100%; flex: 1; }
    .filters .results-count { margin-left: 0; }
    .hero { padding: 28px 20px; }
    .hero h1 { font-size: 1.6em; }
    h1 { font-size: 1.5em; }
    table { font-size: 0.85em; }
    table th, table td { padding: 8px; }
}

@media (max-width: 480px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* ============================================================
   Carrito - boton flotante + panel lateral
   ============================================================ */
#cart-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 90;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 30px;
    padding: 12px 20px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    margin: 0;
    transition: transform var(--transition), background var(--transition);
}
#cart-toggle:hover { background: var(--accent-hover); transform: translateY(-2px); }
#cart-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    border-radius: 12px;
    padding: 1px 8px;
    margin-left: 6px;
    font-size: 0.85em;
    min-width: 22px;
    text-align: center;
}

#cart-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 100;
}
#cart-backdrop.open { opacity: 1; pointer-events: auto; }

#cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 92vw;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 110;
    display: flex;
    flex-direction: column;
}
#cart-panel.open { transform: translateX(0); }

#cart-panel header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#cart-panel header h2 { margin: 0; font-size: 1.15em; }
#cart-close {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.6em;
    cursor: pointer;
    padding: 0 8px;
    margin: 0;
    line-height: 1;
}
#cart-close:hover { color: var(--accent); background: transparent; }

#cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.cart-empty { color: var(--text-muted); text-align: center; margin-top: 40px; }

.cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
    font-weight: 600;
    font-size: 0.92em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-price { font-size: 0.85em; color: var(--text-muted); margin: 2px 0 8px; }
.cart-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
}
.cart-item-actions button {
    margin: 0;
    padding: 2px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.95em;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.cart-item-actions button:hover { background: var(--accent); border-color: var(--accent); }
.cart-item-actions input {
    width: 50px;
    padding: 2px 4px;
    text-align: center;
    background: var(--bg-page);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    margin: 0;
}
.cart-item-actions .cart-remove {
    margin-left: auto;
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}
.cart-item-actions .cart-remove:hover { background: var(--danger); color: #fff; }
.cart-item-subtotal { font-size: 0.85em; color: var(--text-muted); }
.cart-item-subtotal strong { color: var(--accent); }

#cart-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}
#cart-footer .cart-total {
    font-size: 1.05em;
    margin-bottom: 12px;
    text-align: right;
}
#cart-footer .cart-total strong { color: var(--accent); font-size: 1.15em; }
#cart-footer .btn { width: 100%; margin: 0 0 8px; text-align: center; }
#cart-footer .btn:last-child { margin-bottom: 0; }


