/**
 * Kalimati Daily Prices
 */

.kalimati-prices-wrapper {
    width: 100%;
    margin: 25px 0;
    font-family: inherit;
    color: #222;
}

/* Header */

.kalimati-prices-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.kalimati-title {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.3;
    font-weight: 700;
}

.kalimati-date {
    color: #666;
    font-size: 14px;
}

.kalimati-count {
    background: #f0fdf4;
    color: #15803d;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

/* Search */

.kalimati-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.kalimati-search {
    width: 100%;
    max-width: 400px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111;
    font-size: 15px;
    box-sizing: border-box;
}

.kalimati-search:focus {
    outline: none;
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.12);
}

.kalimati-clear {
    min-height: 44px;
    padding: 10px 18px;
    border: 0;
    border-radius: 6px;
    background: #374151;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.kalimati-clear:hover {
    background: #111827;
}

.kalimati-no-results {
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-align: center;
    color: #666;
}

/* Table */

.kalimati-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.kalimati-table {
    width: 100%;
    min-width: 700px;
    margin: 0;
    border-collapse: collapse;
    background: #fff;
    font-size: 15px;
}

.kalimati-table th {
    padding: 13px 14px;
    background: #166534;
    color: #fff;
    border: 0;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.kalimati-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.kalimati-table tbody tr:last-child td {
    border-bottom: 0;
}

.kalimati-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.kalimati-table tbody tr:hover {
    background: #f0fdf4;
}

.kalimati-number {
    width: 50px;
    color: #6b7280;
}

.kalimati-commodity {
    font-weight: 600;
    color: #111827;
}

.kalimati-price {
    white-space: nowrap;
}

.kalimati-average {
    font-weight: 700;
    color: #166534;
}

.kalimati-currency {
    font-size: 12px;
    color: #6b7280;
    margin-right: 2px;
}

/* Footer */

.kalimati-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 12px;
    color: #6b7280;
    font-size: 12px;
}

/* Error */

.kalimati-error {
    padding: 15px 18px;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fef2f2;
    color: #b91c1c;
}

/* Tablet */

@media (max-width: 768px) {

    .kalimati-title {
        font-size: 23px;
    }

    .kalimati-prices-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .kalimati-footer {
        flex-direction: column;
        gap: 5px;
    }
}

/* Mobile */

@media (max-width: 600px) {

    .kalimati-prices-wrapper {
        margin: 15px 0;
    }

    .kalimati-title {
        font-size: 21px;
    }

    .kalimati-toolbar {
        flex-direction: column;
    }

    .kalimati-search {
        max-width: none;
    }

    .kalimati-clear {
        width: 100%;
    }

    /*
     * Convert table into cards on mobile.
     */

    .kalimati-table-container {
        border: 0;
        overflow: visible;
    }

    .kalimati-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .kalimati-table thead {
        display: none;
    }

    .kalimati-table,
    .kalimati-table tbody,
    .kalimati-table tr,
    .kalimati-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .kalimati-table tr {
        margin-bottom: 12px;
        padding: 10px 0;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff !important;
    }

    .kalimati-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 15px;
        padding: 9px 14px;
        border: 0;
        text-align: right;
    }

    .kalimati-table td::before {
        content: attr(data-label);
        color: #6b7280;
        font-weight: 500;
        text-align: left;
    }

    /* attr() content cannot be swapped by hiding a span, so the Nepali column
       names ride along as a second attribute and win only where defined. */
    html[data-market-lang="ne"] .kalimati-table td[data-label-ne]::before {
        content: attr(data-label-ne);
    }

    .kalimati-table .kalimati-commodity {
        display: block;
        padding-top: 14px;
        padding-bottom: 14px;
        background: #f0fdf4;
        color: #166534;
        font-size: 16px;
        text-align: left;
    }

    .kalimati-table .kalimati-commodity::before {
        display: none;
    }

    .kalimati-table .kalimati-number {
        display: none;
    }

    .kalimati-table .kalimati-average {
        font-size: 16px;
    }

}
