/* ============================================================
   PWA Parqueadero & Lavadero — Estilos principales
   ============================================================ */

/* ---------- Variables ---------- */
:root {
    --primary: #1565c0;
    --primary-dark: #0d47a1;
    --primary-light: #42a5f5;
    --accent: #ff6f00;
    --success: #2e7d32;
    --warning: #f57f17;
    --danger: #c62828;
    --info: #0277bd;
    --bg: #f5f5f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a237e;
    --bg-sidebar-hover: #283593;
    --text: #212121;
    --text-secondary: #757575;
    --text-light: #ffffff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.15);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: .2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- Splash Screen ---------- */
#splash-screen {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary) 100%);
    color: #fff; flex-direction: column;
}
.splash-content { text-align: center; }
.splash-icon { font-size: 64px; margin-bottom: 16px; }
.splash-content h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 24px; }
.splash-loader {
    width: 40px; height: 40px; margin: 0 auto;
    border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
#login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary) 100%);
    padding: 16px;
}
.login-card {
    background: #fff; border-radius: var(--radius-lg); padding: 40px 32px;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .material-icons-outlined { font-size: 48px; color: var(--primary); }
.login-header h1 { font-size: 1.4rem; margin-top: 8px; }
.login-header p { color: var(--text-secondary); font-size: .9rem; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: .85rem; color: var(--text-secondary); }
.input-icon { position: relative; }
.input-icon .material-icons-outlined {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 20px; color: var(--text-secondary);
}
.input-icon input, .input-icon select { padding-left: 40px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
input[type="tel"], input[type="url"], select, textarea {
    display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: #fff; transition: border var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-inline { display: flex; gap: 8px; align-items: flex-end; }
.form-inline .form-group { flex: 1; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
    border: none; border-radius: var(--radius); cursor: pointer; font-weight: 500;
    transition: all var(--transition); font-size: .9rem; white-space: nowrap;
    justify-content: center;
}
.btn .material-icons-outlined { font-size: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #e65100; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #01579b; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #e65100; }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon {
    background: none; border: none; cursor: pointer; padding: 8px;
    border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition); color: inherit;
}
.btn-icon:hover { background: rgba(0,0,0,.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin: 12px 0; font-size: .9rem;
}
.alert-danger { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }
.alert-info { background: #e1f5fe; color: var(--info); border: 1px solid #b3e5fc; }

/* ---------- Layout: Sidebar + Main ---------- */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); background: var(--bg-sidebar); color: var(--text-light);
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 1000; transition: transform var(--transition);
    will-change: transform; overflow: hidden;
}

/* Overlay oscuro — siempre en DOM; invisible y sin eventos cuando cerrado */
.sidebar-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
}
.sidebar-overlay.active {
    opacity: 1; pointer-events: auto;
}
.sidebar-header {
    display: flex; align-items: center; gap: 10px; padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header .material-icons-outlined { font-size: 28px; }
.sidebar-title { font-size: 1.1rem; font-weight: 600; }
#sidebar-close { color: #fff; display: none; }

.sidebar-user {
    display: flex; align-items: center; gap: 12px; padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
}
.user-info { display: flex; flex-direction: column; }
.user-info span { font-weight: 500; font-size: .9rem; }
.user-info small { font-size: .75rem; opacity: .7; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sidebar-nav .nav-section { padding: 12px 20px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; opacity: .5; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 20px; cursor: pointer;
    transition: background var(--transition); font-size: .9rem; color: rgba(255,255,255,.85);
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--bg-sidebar-hover); border-left-color: var(--primary-light); color: #fff; font-weight: 500; }
.nav-item .material-icons-outlined { font-size: 20px; }

.sidebar-footer { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer .btn-outline { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.2); }
.sidebar-footer .btn-outline:hover { background: rgba(255,255,255,.1); }
.offline-badge {
    display: flex; align-items: center; gap: 6px; margin-top: 8px;
    font-size: .8rem; color: var(--warning); justify-content: center;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--topbar-height); background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; padding: 0 20px;
    position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
#sidebar-toggle { display: none; }
.topbar h2 { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.connection-dot { width: 10px; height: 10px; border-radius: 50%; }
.connection-dot.online { background: var(--success); }
.connection-dot.offline { background: var(--danger); }
.sync-indicator { display: flex; align-items: center; position: relative; cursor: pointer; color: var(--text-secondary); }
.sync-indicator .badge {
    position: absolute; top: -4px; right: -6px;
    background: var(--danger); color: #fff; font-size: .6rem;
    width: 16px; height: 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.page-content { flex: 1; padding: 20px; overflow-y: auto; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 16px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-flush { padding: 0; }
.card-flush .card-header { padding: 16px 20px; margin-bottom: 0; }

/* ---------- Stats Grid ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.stat-icon.blue { background: #e3f2fd; color: var(--primary); }
.stat-icon.green { background: #e8f5e9; color: var(--success); }
.stat-icon.orange { background: #fff3e0; color: var(--accent); }
.stat-icon.red { background: #ffebee; color: var(--danger); }
.stat-icon.purple { background: #f3e5f5; color: #7b1fa2; }
.stat-info h4 { font-size: 1.5rem; font-weight: 700; }
.stat-info small { color: var(--text-secondary); font-size: .8rem; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; white-space: nowrap; }
.table th { background: var(--bg); font-weight: 600; color: var(--text-secondary); font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
.table tbody tr:hover { background: #f5f5f5; }
.table .actions { display: flex; gap: 4px; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* ---------- Badges ---------- */
.badge-status {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff8e1; color: #e65100; }
.badge-danger { background: #ffebee; color: var(--danger); }
.badge-info { background: #e1f5fe; color: var(--info); }
.badge-secondary { background: #f5f5f5; color: var(--text-secondary); }
.badge-primary { background: #e3f2fd; color: var(--primary); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination button {
    padding: 6px 12px; border: 1px solid var(--border); background: #fff;
    border-radius: var(--radius); cursor: pointer; font-size: .85rem;
    transition: all var(--transition);
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { font-size: .8rem; color: var(--text-secondary); margin: 0 8px; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-content {
    background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 600px;
    max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-content.modal-lg { max-width: 900px; }
.modal-content.modal-sm { max-width: 400px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 3000;
    display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    border-radius: var(--radius); color: #fff; font-size: .9rem;
    box-shadow: var(--shadow-lg); animation: slideIn .3s ease;
    min-width: 280px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: #e65100; }
.toast-info { background: var(--info); }
.toast .material-icons-outlined { font-size: 20px; }
.toast-message { flex: 1; }
.toast-close { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; opacity: .7; }
.toast-close:hover { opacity: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- POS Specific ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; height: calc(100vh - var(--topbar-height) - 40px); }
.pos-products { overflow-y: auto; }
.pos-cart { display: flex; flex-direction: column; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.product-card {
    background: #fff; border: 2px solid var(--border); border-radius: var(--radius);
    padding: 12px; cursor: pointer; transition: all var(--transition); text-align: center;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.product-card .product-name { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.product-card .product-price { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.product-card .product-code { font-size: .7rem; color: var(--text-secondary); }
.product-card.servicio { border-left: 4px solid var(--info); }
.product-card.producto { border-left: 4px solid var(--success); }

.cart-items { flex: 1; overflow-y: auto; }
.cart-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 0;
    border-bottom: 1px solid var(--border); font-size: .85rem;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 500; }
.cart-item-price { color: var(--text-secondary); font-size: .8rem; }
.cart-qty { display: flex; align-items: center; gap: 4px; }
.cart-qty button { width: 28px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.cart-qty input { width: 40px; text-align: center; border: 1px solid var(--border); border-radius: 4px; padding: 4px; }
.cart-total { font-weight: 700; min-width: 70px; text-align: right; }
.cart-remove { color: var(--danger); }

.cart-summary { border-top: 2px solid var(--border); padding-top: 12px; }
.cart-summary-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: .9rem; }
.cart-summary-row.total { font-size: 1.2rem; font-weight: 700; color: var(--primary); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* Product type tabs */
.tab-bar { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab-item {
    padding: 10px 20px; cursor: pointer; font-weight: 500; font-size: .9rem;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all var(--transition); color: var(--text-secondary);
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Filters bar */
.filters-bar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px;
    padding: 12px 16px; background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.filters-bar input, .filters-bar select { max-width: 200px; padding: 8px 12px; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 36px; width: 100%; }
.search-box .material-icons-outlined { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 18px; color: var(--text-secondary); }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-secondary);
}
.empty-state .material-icons-outlined { font-size: 64px; opacity: .3; margin-bottom: 12px; }
.empty-state h4 { font-size: 1.1rem; margin-bottom: 4px; color: var(--text); }
.empty-state p { font-size: .9rem; }

/* ---------- Loading Spinner ---------- */
.loading-spinner {
    display: flex; align-items: center; justify-content: center; padding: 40px;
}
.loading-spinner::after {
    content: ''; width: 32px; height: 32px;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .6s linear infinite;
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }
.font-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.p-0 { padding: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-100 { width: 100%; }

.currency::before { content: '$ '; }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .btn, .pagination, .filters-bar, .toast-container { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------- Tablet landscape (769px - 1024px) ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-width: 220px; }
    .page-content { padding: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .pos-layout { grid-template-columns: 1fr 320px; }
}

/* ---------- Responsive móvil (≤ 768px) ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 85vw);
        pointer-events: none;
    }
    .sidebar.open {
        transform: translateX(0);
        pointer-events: auto;
    }
    #sidebar-close { display: block; }
    #sidebar-toggle { display: inline-flex; }
    .main-content { margin-left: 0; }

    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar input, .filters-bar select { max-width: 100%; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .form-row { flex-direction: column; }

    .modal-content { max-width: 100%; margin: 8px; }
    .modal-content.modal-lg { max-width: 100%; }

    .toast-container { left: 16px; right: 16px; bottom: 16px; max-width: 100%; }

    .table th, .table td { padding: 8px 10px; font-size: .8rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px 20px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bdbdbd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9e9e9e; }

/* ============================================================
   Módulo Logs de Ejecución
   ============================================================ */
.log-table { font-size: .82rem; border-collapse: collapse; }
.log-table td, .log-table th { vertical-align: middle; }
.log-ts { font-family: monospace; font-size: .8rem; white-space: nowrap; color: var(--text-muted); }
.log-msg { font-family: monospace; font-size: .8rem; word-break: break-all; }

/* Row tinting by level */
.log-row-error   { background: rgba(220, 53,  69,  .06); }
.log-row-warning { background: rgba(255, 193,  7,  .08); }
.log-row-error:hover   { background: rgba(220, 53,  69,  .13) !important; }
.log-row-warning:hover { background: rgba(255, 193,  7,  .15) !important; }

/* Keyword highlight */
mark.log-highlight {
    background: #fff176;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
