/*
 * Twitch Remote Control - Styling
 * Copyright (c) 2025 Twitch Remote Contributors
 * Licensed under MIT License
 */

body {
    background-color: #111827;
    margin: 0;
    font-family: sans-serif;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    padding-top: 54px; /* identisch zur Höhe der Top-Nav */
}

/* Jede View fullscreen */
.app-view {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    border: 4px solid #374151;
    border-top: 4px solid #22c55e;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0); }
    100% { transform: rotate(360deg); }
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-gap: 10px;
}

/* Buttons */
.streamdeck-btn {
    width: 100px;
    height: 100px;
    background-color: #374151;
    color: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.25s;
    user-select: none;
    outline: none;
}

.streamdeck-btn:active {
    background-color: #4B5563;
}

.streamdeck-btn.active {
    background-color: #3b82f6;
}

.streamdeck-btn i {
    font-size: 2.4rem;
    line-height: 1;
    margin-bottom: 4px;
    pointer-events: none;
}

.streamdeck-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: #1f2937;
    padding: 0.5rem;
    border-top: 1px solid #374151;
}

.nav-btn {
    flex: 1;
    margin: 0 0.3rem;
    background: #374151;
    border: none;
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 1.5rem;
    padding: 0.5rem 0;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.nav-btn:hover,
.nav-btn:focus {
    background: #4b5563;
    color: #22c55e;
}

.nav-btn.active {
    background: #22c55e;
    color: #fff;
}

/* Config Editor Overlay - Verbesserte Formatierung */
#config-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#config-editor-overlay.hidden {
    display: none;
}

#config-editor-overlay .overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
}

#config-editor-overlay .overlay-content {
    position: relative;
    background: #1f2937;
    padding: 2rem;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Formular-Styling - bessere Abstände */
#edit-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#config-editor-overlay label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: #e5e7eb;
    font-size: 0.95rem;
    font-weight: 500;
}

#config-editor-overlay input,
#config-editor-overlay textarea,
#config-editor-overlay select {
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid #374151;
    background: #111827;
    color: #f3f4f6;
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#config-editor-overlay input:focus,
#config-editor-overlay textarea:focus,
#config-editor-overlay select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#config-editor-overlay textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
    font-family: 'Courier New', monospace;
}

/* Icon Picker Wrapper */
#config-editor-overlay .icon-picker-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

#config-editor-overlay .icon-picker-wrapper input {
    flex: 1;
}

.picker-btn {
    background: #3b82f6;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    color: white;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.picker-btn:hover {
    background: #f97316;
    border-color: #f97316;
}

/* Payload Container - neuer Container für dynamische Felder */
#payload-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 12px;
    margin-top: 0.5rem;
}

#payload-container label {
    margin-bottom: 0;
    color: #d1d5db;
}

#payload-container:empty {
    display: none;
}

/* Action Buttons */
#config-editor-overlay .overlay-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid #374151;
    margin-top: 1rem;
}

.overlay-actions .nav-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    border-radius: 8px;
    min-width: 80px;
    margin: 0;
}

/* Icon Picker */
#icon-picker {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

#icon-picker.hidden {
    display: none;
}

.icon-picker-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
}

.icon-picker-content {
    position: relative;
    background: #1f2937;
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1101;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.icon-picker-content h3 {
    margin: 0 0 1.5rem 0;
    color: #f3f4f6;
    font-size: 1.25rem;
    font-weight: 600;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.icon-grid button {
    background: #374151;
    border: 2px solid #4b5563;
    color: #e5e7eb;
    font-size: 1.5rem;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-grid button:hover {
    background: #f97316;
    border-color: #f97316;
    color: #fff;
    transform: scale(1.05);
}

/* Add/Delete Buttons */
.btn-add {
    background: #16a34a;
    color: #fff;
}
.btn-add:hover {
    background: #22c55e;
}

.btn-delete-zone {
    background: #dc2626;
    color: #fff;
}
.btn-delete-zone.drag-over {
    background: #b91c1c;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: #1f2937;
    padding: 0.5rem;
    border-bottom: 1px solid #374151;
    z-index: 1001;
    height: 44px;
}

.top-nav .nav-btn:hover,
.top-nav .nav-btn:focus {
    background: #4b5563;
    color: #22c55e;
}

.top-nav .nav-btn.active {
    background: #22c55e;
    color: #fff;
}

.feedback-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#feedback-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

#feedback-form textarea {
    width: 300px;
    height: 600px;
    resize: none;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #374151;
    background: #111827;
    color: #f3f4f6;
    font-size: 1rem;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.feedback-actions {
    text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
    #config-editor-overlay .overlay-content {
        padding: 1.5rem;
        width: 95%;
        margin: 1rem;
    }

    #edit-form {
        gap: 1.25rem;
    }

    #payload-container {
        padding: 1rem;
        gap: 0.75rem;
    }

    .overlay-actions {
        flex-direction: column;
    }

    .icon-picker-content {
        padding: 1rem;
        width: 95%;
    }

    .icon-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.4rem;
    }
}

.streamdeck-btn {
    position: relative;
}

/* Alte #icon-preview Styles entfernt - jetzt durch .icon-preview-button ersetzt */

/* Icon-Picker Verbesserungen */
.icon-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-picker-wrapper input {
    flex: 1;
}

.picker-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.picker-btn:hover {
    background: #5a6268;
}

/* Color Picker Styles */
.color-preview-diagonal {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    border: 2px solid #4b5563;
    background: linear-gradient(-45deg, #3b82f6 50%, #0c1844 50%);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.color-preview-diagonal:hover {
    border-color: #6b7280;
    transform: translateY(-1px);
}

/* Color Picker Overlay */
#color-picker {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1102;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-picker-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
}

.color-picker-content {
    background: #1f2937;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 280px;
    position: relative;
    border: 1px solid #374151;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    justify-self: center;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #3b82f6;
}

/* Icon Preview Button - Neue Styles für feste Icon-Vorschau */
.icon-preview-button {
    background: #374151;
    border: 2px solid #4b5563;
    border-radius: 8px;
    color: #e5e7eb;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    font-size: 1.2rem;
}

.icon-preview-button:hover {
    background: #f97316;
    border-color: #f97316;
    color: #fff;
    transform: scale(1.05);
}

/* Drag & Drop Visual Feedback für Touchscreens */
.streamdeck-btn.dragging {
    opacity: 0.6;
    transform: scale(0.95);
}

.streamdeck-btn.drop-target {
    background-color: #6b7280 !important;  /* Helleres Grau statt Grün */
    transform: scale(1.02);                 /* Nur leicht größer */
    transition: all 0.2s ease;
}

/* Twitch Login Button - Wie Buttons in der Button-Ansicht */
.login-btn-twitch {
    background: #2d1b4e !important; /* Sehr dunkler Lilaton als Hintergrund */
    color: white !important;
    border: 3px solid #9146ff !important; /* Heller lila Rand */
}

.login-btn-twitch:hover,
.login-btn-twitch:focus {
    background: #3d2458 !important; /* Etwas hellerer dunkler Lilaton beim Hover */
    border-color: #9146ff !important;
    color: white !important;
}

.login-btn-twitch:active,
.login-btn-twitch.active {
    background: #9146ff !important; /* Komplett aufleuchten in hellem Lila */
    border-color: #9146ff !important;
    color: white !important;
}

.login-btn-twitch i {
    font-size: 2rem !important; /* Größeres Twitch Logo */
    margin-bottom: 8px;
}