/* ============================================================
   tienda.css  --  Store / Tablet dashboard styles
   Nexus Autoparts — tablet-first, touch-friendly
   ============================================================ */

/* --- Base overrides for tienda page --- */
body {
    margin: 0;
    padding: 0;
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

/* --- Header --- */
.t-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    background: rgba(18, 18, 26, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
}

.t-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.t-logo-mark {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent) 0%, #ff4500 100%);
    border-radius: 9px;
    box-shadow: 0 3px 14px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.t-logo-mark::after {
    content: '\2699\FE0F';
    font-size: 1.2rem;
}

.t-brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.t-brand-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.t-brand-sub {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* --- Header center: search --- */
.t-header-center {
    flex: 1;
    max-width: 420px;
    margin: 0 1rem;
}

.t-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.t-search-icon {
    position: absolute;
    left: 0.7rem;
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    pointer-events: none;
}

.t-search-box input {
    width: 100%;
    padding: 0.55rem 0.8rem 0.55rem 2.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.t-search-box input:focus {
    border-color: var(--accent);
}

.t-search-box input::placeholder {
    color: var(--text-secondary);
}

.t-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    display: none;
    z-index: 200;
}

.t-search-results.active {
    display: block;
}

.t-search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.t-search-result-item:last-child {
    border-bottom: none;
}

.t-search-result-item:hover,
.t-search-result-item:active {
    background: var(--bg-hover);
}

.t-search-result-item .sri-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
}

.t-search-result-item .sri-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.4rem;
}

/* --- Header right: clock --- */
.t-header-right {
    flex-shrink: 0;
}

.t-clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

/* --- Main --- */
.t-main {
    padding: 4.2rem 1rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- KPI Row --- */
.t-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.t-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.t-kpi:active {
    transform: scale(0.98);
}

/* Colored left accent bar */
.t-kpi::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
}

.t-kpi[data-color="accent"]::before { background: var(--accent); }
.t-kpi[data-color="success"]::before { background: var(--success); }
.t-kpi[data-color="info"]::before { background: var(--info); }
.t-kpi[data-color="warning"]::before { background: var(--warning); }

.t-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.t-kpi-icon svg {
    width: 22px;
    height: 22px;
}

.t-kpi[data-color="accent"] .t-kpi-icon { background: rgba(255, 107, 53, 0.12); color: var(--accent); }
.t-kpi[data-color="success"] .t-kpi-icon { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.t-kpi[data-color="info"] .t-kpi-icon { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.t-kpi[data-color="warning"] .t-kpi-icon { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.t-kpi-data {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.t-kpi-value {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-kpi-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.t-kpi-count {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 0.2rem;
}

/* --- Content Grid --- */
.t-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

/* --- Cards --- */
.t-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.t-card-full {
    min-height: 0;
}

.t-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.t-card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.8rem;
}

.t-card-header .t-card-title {
    margin-bottom: 0;
}

.t-see-all {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.t-see-all:hover,
.t-see-all:active {
    background: rgba(255, 107, 53, 0.1);
}

/* --- Quick Actions Grid --- */
.t-actions-card {
    padding-bottom: 0.8rem;
}

.t-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.t-action {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: transform 0.15s, background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.t-action:active {
    transform: scale(0.96);
}

.t-action:hover {
    background: var(--bg-hover);
}

.t-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.t-action-icon svg {
    width: 20px;
    height: 20px;
}

.t-action[data-color="accent"] .t-action-icon { background: rgba(255, 107, 53, 0.12); color: var(--accent); }
.t-action[data-color="accent"]:hover { border-color: var(--accent); }
.t-action[data-color="info"] .t-action-icon { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.t-action[data-color="info"]:hover { border-color: var(--info); }
.t-action[data-color="success"] .t-action-icon { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.t-action[data-color="success"]:hover { border-color: var(--success); }
.t-action[data-color="warning"] .t-action-icon { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.t-action[data-color="warning"]:hover { border-color: var(--warning); }

/* --- Debtors List --- */
.t-debtors-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 280px;
    overflow-y: auto;
}

.t-debtor {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.t-debtor:hover,
.t-debtor:active {
    background: var(--bg-hover);
    border-color: var(--danger);
}

.t-debtor-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.t-debtor-invoices {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.t-debtor-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--danger);
}

/* --- Invoice List --- */
.t-invoice-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 320px;
    overflow-y: auto;
}

.t-invoice {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background 0.15s;
}

.t-invoice:hover,
.t-invoice:active {
    background: var(--bg-hover);
}

.t-invoice-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.t-invoice-folio {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
}

.t-invoice-customer {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.t-invoice-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.t-invoice-total {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.85rem;
}

.t-invoice-status {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.t-invoice-status.paid {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.t-invoice-status.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.t-invoice-status.partial {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.t-invoice-status.cancelled {
    background: rgba(255, 68, 68, 0.15);
    color: var(--danger);
}

/* --- Today's Payments card --- */
.t-today-payments {
    text-align: center;
    padding: 0.5rem 0;
}

.t-today-amount {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    color: var(--success);
    line-height: 1.2;
}

.t-today-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* --- Empty state --- */
.t-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* --- Scrollbar (minimal for touch) --- */
.t-debtors-list::-webkit-scrollbar,
.t-invoice-list::-webkit-scrollbar,
.t-search-results::-webkit-scrollbar {
    width: 4px;
}

.t-debtors-list::-webkit-scrollbar-track,
.t-invoice-list::-webkit-scrollbar-track,
.t-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.t-debtors-list::-webkit-scrollbar-thumb,
.t-invoice-list::-webkit-scrollbar-thumb,
.t-search-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* --- Responsive --- */

/* Tablet landscape (default target) */
@media (max-width: 1024px) {
    .t-main {
        padding: 4rem 0.8rem 1.2rem;
    }

    .t-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet portrait / large phone */
@media (max-width: 768px) {
    .t-header-center {
        display: none;
    }

    .t-main {
        padding: 3.8rem 0.6rem 1rem;
    }

    .t-content {
        grid-template-columns: 1fr;
    }

    .t-kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .t-kpi {
        padding: 0.7rem 0.8rem;
    }

    .t-kpi-value {
        font-size: 1.1rem;
    }

    .t-kpi-count {
        display: none;
    }

    .t-actions-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Small phone */
@media (max-width: 480px) {
    .t-kpi-row {
        grid-template-columns: 1fr 1fr;
    }

    .t-kpi-icon {
        width: 32px;
        height: 32px;
    }

    .t-kpi-icon svg {
        width: 18px;
        height: 18px;
    }

    .t-kpi-value {
        font-size: 1rem;
    }

    .t-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Fade-in animation for cards --- */
@keyframes t-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.t-kpi {
    animation: t-fadeIn 0.4s ease both;
}

.t-kpi:nth-child(1) { animation-delay: 0.05s; }
.t-kpi:nth-child(2) { animation-delay: 0.1s; }
.t-kpi:nth-child(3) { animation-delay: 0.15s; }
.t-kpi:nth-child(4) { animation-delay: 0.2s; }

.t-card {
    animation: t-fadeIn 0.4s ease both;
    animation-delay: 0.25s;
}

.t-content .t-col:nth-child(2) .t-card {
    animation-delay: 0.3s;
}

.t-content .t-col:nth-child(2) .t-card:nth-child(2) {
    animation-delay: 0.35s;
}
