/* HomeAssistant-like Dashboard Styles */

.ha-dashboard {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

/* Transparentní pozadí pro dashboard, když má body obrázek pozadí */
body[style*="background-image"] .ha-dashboard {
    background: transparent !important;
}

.ha-places-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.ha-places-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex: 1;
    padding: 4px 0;
}

.ha-places-scroll::-webkit-scrollbar {
    height: 4px;
}

.ha-places-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.ha-places-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.ha-place-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.ha-place-btn:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
}

.ha-place-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ha-place-btn i {
    font-size: 16px;
}

.ha-add-place-btn {
    border-style: dashed;
    color: var(--text-secondary);
}

.ha-add-place-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.ha-edit-controls {
    display: flex;
    gap: 8px;
    margin-left: 15px;
    flex-shrink: 0;
}

.ha-edit-btn,
.ha-save-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.ha-edit-btn:hover,
.ha-save-btn:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
}

.ha-save-btn {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ha-save-btn:hover {
    box-shadow: 0 0 12px var(--success);
}

.ha-backup-controls {
    display: flex;
    gap: 8px;
}

.ha-backup-btn,
.ha-restore-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ha-backup-btn:hover,
.ha-restore-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.ha-backup-btn i,
.ha-restore-btn i {
    font-size: 14px;
}

.ha-main-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.ha-place-header {
    margin-bottom: 20px;
}

.ha-place-title {
    margin: 0;
    font-size: 24px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ha-place-title i {
    color: var(--primary);
}

.ha-blocks-toolbar {
    margin-bottom: 16px;
}

.ha-entities-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ha-entities-block {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}

.ha-block-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.ha-block-size-controls {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.ha-size-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
}

.ha-size-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ha-size-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.ha-block-title {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.ha-block-title:focus {
    outline: none;
    background: var(--surface);
}

.ha-remove-block-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: var(--danger);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ha-entities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.ha-entity-card {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.ha-entity-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ha-entity-card.dragging {
    opacity: 0.5;
}

.ha-entity-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.ha-entity-icon {
    font-size: 32px;
    transition: all 0.3s ease;
}

.ha-entity-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ha-entity-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ha-entity-state {
    font-size: 11px;
    color: var(--text-secondary);
}

.ha-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ha-entity-card:hover .ha-remove-btn {
    opacity: 1;
}

.ha-add-entity-card {
    background: var(--surface-light);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    min-height: 100px;
}

.ha-add-entity-card:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ha-add-entity-card i {
    font-size: 24px;
}

.ha-add-block-card {
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 32px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.ha-add-block-card:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ha-add-block-card i {
    font-size: 28px;
}

/* Entities list modal */
.ha-entities-list {
    max-height: 400px;
    overflow-y: auto;
}

.ha-entity-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ha-entity-option:hover {
    background: var(--surface);
}

.ha-entity-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ha-entity-option i {
    font-size: 20px;
    color: var(--primary);
}

/* Tab styles */
.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:hover {
    color: var(--primary);
}

/* Long press indicator */
.long-press-indicator {
    display: none;
    position: fixed;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 12px;
    font-size: 14px;
    z-index: 1100;
    gap: 8px;
    animation: pulse 1s infinite;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Color picker */
.color-modal-content {
    max-width: 360px;
}

.color-picker-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.color-wheel-container {
    position: relative;
}

#colorWheel {
    cursor: crosshair;
    border-radius: 50%;
}

.color-preview {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.color-info {
    text-align: center;
}

.color-hex {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-family: monospace;
}

.color-presets {
    width: 100%;
}

.preset-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.preset-color {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-color:hover {
    transform: scale(1.1);
}

.preset-color.active {
    border-color: white;
}

.color-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

/* Responsive block layout */
@media (min-width: 1200px) {
    .ha-entities-container {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    
    .ha-entities-block {
        flex: 1 1 calc(50% - 10px);
        min-width: 300px;
        max-width: calc(50% - 10px);
    }
    
    .ha-add-block-card {
        flex: 1 1 calc(50% - 10px);
        min-width: 300px;
        max-width: calc(50% - 10px);
        min-height: 150px;
    }
}

@media (min-width: 1600px) {
    .ha-entities-block {
        flex: 1 1 calc(33.333% - 14px);
        min-width: 350px;
        max-width: calc(33.333% - 14px);
    }
    
    .ha-add-block-card {
        flex: 1 1 calc(33.333% - 14px);
        min-width: 350px;
        max-width: calc(33.333% - 14px);
    }
}

@media (max-width: 1199px) {
    .ha-entities-container {
        flex-direction: column;
    }
    
    .ha-entities-block {
        width: 100%;
    }
    
    .ha-add-block-card {
        width: 100%;
    }
}

/* Block width controls for edit mode */
.ha-entities-block.half-width {
    flex: 1 1 calc(50% - 10px) !important;
    min-width: 300px !important;
    max-width: calc(50% - 10px) !important;
}

.ha-entities-block.third-width {
    flex: 1 1 calc(33.333% - 14px) !important;
    min-width: 300px !important;
    max-width: calc(33.333% - 14px) !important;
}

.ha-entities-block.full-width {
    flex: 1 1 100% !important;
    max-width: 100% !important;
}

.preset-color.active {
    border-color: white;
}

.color-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Notification styles */
.notification {
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.notification-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    word-wrap: break-word;
}

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Notification queue positioning */
.notification:nth-child(2) {
    top: 90px;
}

.notification:nth-child(3) {
    top: 160px;
}

.notification:nth-child(4) {
    top: 230px;
}

.notification:nth-child(5) {
    top: 300px;
}

/* Field error styles */

/* Mobile responsive styles */
@media (max-width: 768px) {
    .ha-places-bar {
        flex-wrap: wrap;
    }
    
    .ha-places-scroll {
        order: 2;
        width: 100%;
    }
    
    .ha-edit-controls {
        order: 1;
    }
    
    .ha-entities-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .ha-entity-card {
        padding: 12px;
    }
    
    .ha-entity-icon {
        font-size: 24px;
    }
}
.field-error {
    color: #ff4444;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

.form-input.error {
    border-color: #ff4444 !important;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.1);
}

/* Backup controls */
.ha-backup-controls {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.ha-backup-btn,
.ha-restore-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ha-backup-btn:hover,
.ha-restore-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.ha-backup-btn i,
.ha-restore-btn i {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .ha-places-bar {
        flex-wrap: wrap;
    }
    
    .ha-edit-controls {
        width: 100%;
    }
    
    .ha-entities-container {
        flex-direction: column;
    }
    
    .ha-entities-block {
        width: 100%;
    }
    
    .ha-add-block-card {
        width: 100%;
    }
    
    .ha-add-entity-card {
        width: 100%;
    }
    
    .modal-content {
        max-width: 90%;
    }
    
    .ha-place-title {
        font-size: 20px;
    }
    
    .ha-block-title {
        font-size: 16px;
    }
    
    .ha-entity-name {
        font-size: 12px;
    }
    
    .ha-entity-state {
        font-size: 10px;
    }
    
    .ha-entity-icon {
        font-size: 28px;
    }
    
    .ha-add-entity-card i {
        font-size: 20px;
    }
    
    .ha-add-block-card i {
        font-size: 24px;
    }
}
