/* =========================================================
   Home Assistant Sensor Widget – Styles
   ========================================================= */

/* ---- Grid ---- */
.ha-sensor-grid {
    display: grid;
    grid-template-columns: repeat(var(--ha-columns, 3), 1fr);
    gap: 1.25rem;
    margin: 1.5rem 0;
}

@media (max-width: 900px) {
    .ha-sensor-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .ha-sensor-grid { grid-template-columns: 1fr; }
}

/* ---- Card ---- */
.ha-sensor-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem 1.375rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: box-shadow .2s ease, transform .2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ha-sensor-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    transform: translateY(-2px);
}

.ha-sensor-card--error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* Card Header */
.ha-sensor-card__header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
}

.ha-sensor-card__icon {
    font-size: 1.4rem;
    line-height: 1;
}

.ha-sensor-card__name {
    font-size: .875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card Value */
.ha-sensor-card__value {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: .75rem;
    letter-spacing: -.02em;
}

.ha-sensor-card__unit {
    font-size: 1rem;
    font-weight: 500;
    opacity: .8;
}

/* Progress Bar */
.ha-sensor-card__progress {
    height: 6px;
    background: #f3f4f6;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: .6rem;
}

.ha-sensor-card__progress-bar {
    height: 100%;
    border-radius: 99px;
    transition: width .4s ease;
}

/* Timestamp */
.ha-sensor-card__updated {
    font-size: .75rem;
    color: #9ca3af;
    margin-top: .25rem;
}

/* ---- Compact Inline ---- */
.ha-sensor-compact {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: .2rem .6rem;
    font-size: .9rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ha-sensor-compact__icon { font-size: 1rem; }
.ha-sensor-compact__name { color: #6b7280; }

/* ---- Table ---- */
.ha-sensor-table-wrap {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.ha-sensor-table {
    width: 100%;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: .9rem;
}

.ha-sensor-table thead tr {
    background: #f3f4f6;
}

.ha-sensor-table th,
.ha-sensor-table td {
    padding: .75rem 1rem;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.ha-sensor-table th {
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .05em;
}

.ha-sensor-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.ha-sensor-table tbody tr:hover {
    background: #eff6ff;
}

.ha-sensor-table__error td {
    color: #991b1b;
    background: #fef2f2 !important;
}

/* ---- Error message ---- */
.ha-sensor-error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .9rem;
}

/* ---- Dark mode support ---- */
@media (prefers-color-scheme: dark) {
    .ha-sensor-card {
        background: #1e1e2e;
        border-color: #313244;
        color: #cdd6f4;
    }
    .ha-sensor-card__name  { color: #a6adc8; }
    .ha-sensor-card__updated { color: #585b70; }
    .ha-sensor-card__progress { background: #313244; }
    .ha-sensor-compact     { background: #181825; border-color: #313244; }
    .ha-sensor-compact__name { color: #a6adc8; }
    .ha-sensor-table th, .ha-sensor-table td { border-color: #313244; }
    .ha-sensor-table thead tr { background: #181825; }
    .ha-sensor-table th    { color: #a6adc8; }
    .ha-sensor-table tbody tr:nth-child(even) { background: #181825; }
    .ha-sensor-table tbody tr:hover { background: #1e1e2e; }
}
