/* ============================================
   Forms & Inputs
   ============================================ */
form {
    margin: var(--spacing-lg) 0;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: var(--spacing-md);
    margin: var(--spacing-xs) 0;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    /* Verhindert Zoom auf iOS */
    min-height: var(--touch-min);
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ============================================
   Buttons
   ============================================ */
button {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-top: var(--spacing-sm);
    transition: all 0.2s;
    min-height: var(--touch-min);
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Tablet/Desktop Button width override */
@media (min-width: 769px) {
    button {
        width: auto;
    }
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

button:active::before {
    width: 300px;
    height: 300px;
}

button:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(108, 92, 231, 0.3);
}

button:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

/* Back Button */
.back-button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.back-button:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

/* Logout Button */
.logout-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.2s;
    width: 100%;
    min-height: var(--touch-min);
    margin-top: var(--spacing-lg);
}

.logout-btn:hover {
    background: #c0392b;
}

/* Toggle Button */
.toggle-btn,
.subscribe-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.2s;
    min-height: var(--touch-min);
    width: 100%;
}

@media (min-width: 769px) {

    .toggle-btn,
    .subscribe-btn {
        width: auto;
    }
}

.toggle-btn:hover,
.subscribe-btn:hover {
    background: var(--accent-secondary);
}

.toggle-btn.disabled {
    background: var(--error);
}

.toggle-btn.disabled:hover {
    background: #c0392b;
}

.toggle-btn.enabled {
    background: var(--success);
}

.toggle-btn.enabled:hover {
    background: #229954;
}

/* ============================================
   Modals (Bottom-Sheet Style für Mobile)
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 11000;
    display: flex;
    align-items: center !important;
    /* Center vertically in viewport */
    justify-content: center !important;
    padding: var(--spacing-md) !important;
    /* Equal padding on all sides */
    margin: 0 !important;
    pointer-events: auto;
}

.modal-content {
    position: relative !important;
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-xl) !important;
    max-width: 600px !important;
    /* Increased from 500px for wider feel */
    width: 96% !important;
    /* Almost full width */
    max-height: 80vh !important;
    /* Ensure it fits with padding */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: fadeIn 0.3s ease;
    /* Fade in animation that preserves centering */
    animation-fill-mode: forwards;
    /* Keep final animation state */
    z-index: 11001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    box-sizing: border-box;
    margin: auto !important;
    /* Center both horizontally and vertically (works with flex parent) */
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    /* Ensure no absolute positioning */
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-start !important;
        /* Start from top on mobile */
        justify-content: center !important;
        padding: 8vh var(--spacing-sm) var(--spacing-sm) !important;
        /* Padding from top on mobile */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        max-height: 85vh !important;
        /* Ensure it fits with top padding */
        width: 98% !important;
        /* Almost full width on mobile */
        margin: 0 auto !important;
        /* Center horizontally */
    }
}

@media (min-width: 1025px) {
    .modal-overlay {
        padding: 8vh var(--spacing-md) var(--spacing-md) !important;
        /* More padding on top for desktop */
    }

    .modal-content {
        max-width: 800px !important;
        padding: var(--spacing-xl);
    }

    .modal-header {
        flex-direction: row;
        justify-content: space-between;
    }

    .modal-close {
        width: auto;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.modal-close {
    background: #444;
    border: none;
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    min-height: var(--touch-min);
    width: 100%;
    font-weight: 600;
}

.modal-close:hover {
    background: #555;
}

/* Target Selection in Modal */
.target-player {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    margin: var(--spacing-sm) 0;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #444;
    transition: all 0.2s;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.target-player:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

/* ============================================
   Tooltips
   ============================================ */
.effect-tooltip {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    padding: var(--spacing-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    max-width: 300px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.effect-tooltip.visible {
    opacity: 1;
}

.effect-tooltip-title {
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    font-size: 0.95em;
}

.effect-tooltip-description {
    color: var(--text-secondary);
    font-size: 0.85em;
    line-height: 1.4;
    margin-bottom: var(--spacing-xs);
}

.effect-tooltip-meta {
    color: var(--text-muted);
    font-size: 0.75em;
    border-top: 1px solid #444;
    padding-top: var(--spacing-xs);
    margin-top: var(--spacing-xs);
}

/* ============================================
   Badges & Status
   ============================================ */
.influence-badge {
    background: var(--warning);
    padding: 4px var(--spacing-sm);
    border-radius: 3px;
    font-size: 0.85em;
    color: white;
}

.dependency-badge {
    background: var(--info);
    padding: 2px var(--spacing-xs);
    border-radius: 3px;
    margin-right: 5px;
    font-size: 0.9em;
    display: inline-block;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
}

.status-badge.status-stabil {
    background: rgba(46, 213, 115, 0.2);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.3);
}

.status-badge.status-effizient {
    background: rgba(46, 213, 115, 0.3);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.4);
}

.status-badge.status-blockierend {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.status-badge.status-unuebersichtlich {
    background: rgba(255, 193, 7, 0.3);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.4);
}

.status-badge.status-ueberlastet {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.status-badge.status-kritisch {
    background: rgba(255, 71, 87, 0.3);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.4);
}

/* Side Effect Badges */
.side-effect-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
}

.side-effect-badge.side-effect-niedrig {
    background: rgba(46, 213, 115, 0.2);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.3);
}

.side-effect-badge.side-effect-mittel {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.side-effect-badge.side-effect-hoch {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

/* ============================================
   Loading & Messages
   ============================================ */
.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.error-message {
    background: var(--error);
    color: white;
    padding: var(--spacing-md);
    border-radius: 8px;
    margin: var(--spacing-lg) 0;
}

.success-message {
    background: var(--success);
    color: white;
    padding: var(--spacing-md);
    border-radius: 8px;
    margin: var(--spacing-lg) 0;
}

/* ============================================
   Toastify Overrides - Ensure toasts stay in viewport
   ============================================ */
#toast-container {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    z-index: 12000 !important;
    pointer-events: none !important;
    /* Container selbst blockiert keine Klicks */
}

#toast-container > div {
    position: fixed !important;
    /* Ensure toasts are positioned relative to viewport, not document */
    pointer-events: auto !important;
    /* Toast-Elemente selbst sind klickbar */
}