/* ===== Entity/Groups Styles ===== */
/* Optimized for 1920x1200 display */

/* Groups Grid */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 320px));
    gap: 1.75rem;
    justify-content: center;
}

.group-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2.75rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px var(--shadow);
    min-height: 360px;
    text-align: center;
}

.group-card:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--accent);
    box-shadow: 0 8px 24px var(--shadow);
    transform: translateY(-2px);
}

[data-theme="light"] .group-card {
    background: rgba(253, 251, 248, 0.5);
    border: 1px solid var(--border);
}

[data-theme="light"] .group-card:hover {
    background: rgba(255, 255, 255, 0.9);
}

.group-card:active {
    transform: translateY(0);
}

.group-card-arrow {
    display: none;
}

.group-card-icon {
    font-size: 4rem;
    width: 6.5rem;
    height: 6.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 18px;
}

.group-card-icon .group-icon {
    width: 5rem;
    height: 5rem;
    filter: brightness(0) invert(1);
}

/* Hue lightbulb icon - larger to match other icons visually */
.group-card-icon .group-icon[src*="lightbulb-hue"] {
    width: 8rem;
    height: 8rem;
}

/* Light theme: make group icons dark */
[data-theme="light"] .group-card-icon .group-icon {
    filter: brightness(0) invert(0.25);
}

/* Tesla logo for card */
.tesla-logo {
    height: 1.5rem;
    width: auto;
    max-width: 8rem;
    filter: brightness(0) invert(1);
}

[data-theme="light"] .tesla-logo {
    filter: brightness(0) invert(0.2);
}

.group-card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    width: 100%;
}

.group-card-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.group-card-summary {
    font-size: 1rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.group-card-arrow {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.group-card-arrow svg {
    width: 24px;
    height: 24px;
}

.group-card:hover .group-card-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

/* Legacy card-group (kept for compatibility) */
.card-group {
    margin-bottom: 2rem;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.group-icon {
    font-size: 1.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--bg-secondary);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.2s ease;
    border: 3px solid transparent;
}

.card-light,
.card-switch,
.card-fan,
.card-lock {
    cursor: pointer;
}

.card-light:hover,
.card-switch:hover,
.card-fan:hover,
.card-lock:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.card-on {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.card-loading {
    opacity: 0.6;
    pointer-events: none;
}

.card-icon {
    font-size: 2.5rem;
    min-width: 3rem;
    text-align: center;
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-state {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.3rem;
    text-transform: capitalize;
}

.card-on .card-state {
    color: var(--accent);
}

.no-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

/* Sensor-specific */
.card-sensor .card-state,
.card-binary_sensor .card-state {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--info);
}

/* Weather */
.card-weather .card-icon {
    font-size: 3rem;
}

/* Climate */
.card-climate .card-state {
    color: #ff9800;
}

/* ===== Group Modal ===== */
.modal-group {
    width: 95vw;
    max-width: 95vw;
    height: 95vh;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.modal-header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.modal-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-header-title h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.group-modal-icon {
    font-size: 1.75rem;
}

.group-modal-icon-img {
    width: 1.75rem;
    height: 1.75rem;
    filter: invert(45%) sepia(80%) saturate(1000%) hue-rotate(320deg) brightness(95%);
}

.modal-close-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.group-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Entity Rows in Group Modal */
.entity-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.entity-row:last-child {
    border-bottom: none;
}

.entity-toggleable {
    cursor: pointer;
}

.entity-toggleable:hover {
    background: var(--bg-input);
}

.entity-loading {
    opacity: 0.5;
    pointer-events: none;
}

.entity-icon {
    font-size: 1.75rem;
    min-width: 2.5rem;
    text-align: center;
}

.entity-info {
    flex: 1;
    min-width: 0;
}

.entity-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-state {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    text-transform: capitalize;
}

.entity-on .entity-state {
    color: var(--accent);
}

/* Toggle Switch */
.entity-toggle {
    flex-shrink: 0;
}

.toggle-switch {
    width: 52px;
    height: 28px;
    background: var(--bg-input);
    border-radius: 14px;
    position: relative;
    transition: background 0.2s;
    border: 2px solid var(--border);
}

.toggle-switch.on {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch.on .toggle-slider {
    transform: translateX(24px);
}

/* ===== Security Grid Styles ===== */
.security-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0.5rem;
}

.security-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    min-height: 120px;
}

.security-grid-item:hover {
    background: var(--bg-hover);
    transform: scale(1.02);
}

.security-grid-item:active {
    transform: scale(0.98);
}

.security-grid-item.lock-item.locked {
    border-color: var(--success-color, #4caf50);
    background: rgba(76, 175, 80, 0.1);
}

.security-grid-item.lock-item.unlocked {
    border-color: var(--warning-color, #ff9800);
    background: rgba(255, 152, 0, 0.1);
}

.security-grid-item.camera-item {
    border-color: rgba(66, 133, 244, 0.3);
    background: rgba(66, 133, 244, 0.1);
}

.security-grid-item.camera-item:hover {
    border-color: rgba(66, 133, 244, 0.6);
    background: rgba(66, 133, 244, 0.2);
}

.security-item-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.security-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    text-align: center;
}

.security-item-state {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.lock-item.locked .security-item-state {
    color: var(--success-color, #4caf50);
}

.lock-item.unlocked .security-item-state {
    color: var(--warning-color, #ff9800);
}

/* ===== Climate Card Styles ===== */
.climate-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
}

.climate-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.climate-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.climate-temp-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.climate-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.climate-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.climate-btn:active {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(0.95);
}

.climate-temp-display {
    min-width: 80px;
    text-align: center;
}

.climate-target-temp {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.climate-temp-unit {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-left: 2px;
}

.climate-mode-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.climate-mode-control {
    display: flex;
    justify-content: center;
}

.climate-fan-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.climate-fan-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.climate-fan-select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s;
    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='%238197AC' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.75rem;
}

.climate-fan-select:hover,
.climate-fan-select:focus {
    border-color: var(--accent);
    outline: none;
}

.climate-mode-select {
    width: 100%;
    max-width: 200px;
    padding: 0.6rem 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    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='%238197AC' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.climate-mode-select:hover,
.climate-mode-select:focus {
    border-color: var(--accent);
    outline: none;
}

.climate-status {
    display: flex;
    justify-content: center;
}

.climate-action {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.climate-action.heating {
    background: rgba(255, 87, 34, 0.2);
    color: #ff5722;
}

.climate-action.cooling {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
}

.climate-action.heat {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

.climate-action.cool {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
}

.climate-action.auto,
.climate-action.heat_cool {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
}

.climate-action.off {
    background: rgba(96, 125, 139, 0.15);
    color: #607d8b;
}

/* ===== Thermostat Display Styles ===== */
.thermostat-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 0;
}

.thermostat-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1;
}

.thermostat-display .thermostat-action {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--text-secondary);
}

.thermostat-display .thermostat-action.heating {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

.thermostat-display .thermostat-action.cooling {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
}

.thermostat-display .thermostat-action.heat {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

.thermostat-display .thermostat-action.cool {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
}

.thermostat-display .thermostat-action.heat_cool,
.thermostat-display .thermostat-action.auto {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
}

.thermostat-display .thermostat-action.off {
    background: rgba(96, 125, 139, 0.15);
    color: #607d8b;
}

.thermostat-temps-dual {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    margin: 0.5rem 0;
}

.thermostat-temps-dual .temp-low {
    font-size: 3rem;
    font-weight: 600;
    color: #ff9800;
}

.thermostat-temps-dual .temp-high {
    font-size: 3rem;
    font-weight: 600;
    color: #2196f3;
}

.thermostat-temps-dual sup {
    font-size: 1.5rem;
    font-weight: 400;
}

.thermostat-temps-single {
    display: flex;
    align-items: baseline;
    margin: 0.5rem 0;
}

.thermostat-temps-single .temp-target {
    font-size: 3.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.thermostat-temps-single sup {
    font-size: 1.75rem;
    font-weight: 400;
}

.thermostat-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thermostat-current .current-icon {
    font-size: 2rem;
}

.thermostat-current .current-temp {
    font-size: 3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.thermostat-buttons {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 0.5rem;
}

.thermostat-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--shadow);
}

.thermostat-btn:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.thermostat-btn:active {
    background: var(--accent);
    transform: scale(0.95);
}

.thermostat-btn svg {
    width: 24px;
    height: 24px;
}

.thermostat-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.thermostat-footer .climate-mode-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Override climate-card layout for thermostat design */
.entity-row.climate-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem 2rem;
    gap: 0;
}

/* ===== Right-side Temperature Controls ===== */
.thermostat-controls-right {
    display: flex;
    gap: 1rem;
}

.thermostat-controls-right.single {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.thermostat-controls-right.single .temp-target {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.thermostat-controls-right.single sup {
    font-size: 1.25rem;
}

.thermostat-setpoint-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.thermostat-setpoint-vertical.heat {
    border: 2px solid rgba(255, 152, 0, 0.3);
}

.thermostat-setpoint-vertical.cool {
    border: 2px solid rgba(33, 150, 243, 0.3);
}

.thermostat-setpoint-vertical .setpoint-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.thermostat-setpoint-vertical .setpoint-temp {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1;
}

.thermostat-setpoint-vertical .setpoint-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.thermostat-setpoint-vertical.heat .setpoint-temp,
.thermostat-setpoint-vertical.heat .setpoint-label {
    color: #ff9800;
}

.thermostat-setpoint-vertical.cool .setpoint-temp,
.thermostat-setpoint-vertical.cool .setpoint-label {
    color: #2196f3;
}

.thermostat-btn-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.thermostat-btn-sm svg {
    width: 16px;
    height: 16px;
}

.thermostat-setpoint.heat .thermostat-btn-sm:hover,
.thermostat-setpoint-vertical.heat .thermostat-btn-sm:hover {
    background: #ff9800;
    color: #fff;
}

.thermostat-setpoint.cool .thermostat-btn-sm:hover,
.thermostat-setpoint-vertical.cool .thermostat-btn-sm:hover {
    background: #2196f3;
    color: #fff;
}

.thermostat-btn-sm:active {
    transform: scale(0.9);
}

.setpoint-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.setpoint-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.thermostat-setpoint.heat .setpoint-label {
    color: #ff9800;
}

.thermostat-setpoint.cool .setpoint-label {
    color: #2196f3;
}

.setpoint-temp {
    font-size: 1.25rem;
    font-weight: 600;
}

.thermostat-setpoint.heat .setpoint-temp {
    color: #ff9800;
}

.thermostat-setpoint.cool .setpoint-temp {
    color: #2196f3;
}

/* ===== Light Group Expandable Controls ===== */
.light-group-card {
    border-bottom: 1px solid var(--border);
}

.light-group-card:last-child {
    border-bottom: none;
}

.light-group-header {
    position: relative;
    padding-right: 3.5rem;
}

.light-group-expand {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.light-group-expand:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.light-group-expand svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.light-group-card.expanded .light-group-expand svg {
    transform: rotate(180deg);
}

.light-group-members {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--shadow);
}

.light-group-card.expanded .light-group-members {
    max-height: 500px;
}

.light-member {
    padding: 0.75rem 1.5rem 0.75rem 3rem;
    border-bottom: 1px solid var(--border-light);
}

.light-member:last-child {
    border-bottom: none;
}

.light-member .entity-icon {
    font-size: 1.5rem;
    min-width: 2rem;
}

.light-member .entity-name {
    font-size: 0.95rem;
}

.light-member .toggle-switch {
    width: 44px;
    height: 24px;
}

.light-member .toggle-slider {
    width: 16px;
    height: 16px;
}

.light-member .toggle-switch.on .toggle-slider {
    transform: translateX(20px);
}
