/**
 * Comprehensive Design Fixes for Klick-Game
 * Version: 2.0
 * Author: Klick-Game Team
 * 
 * Diese CSS-Datei behebt alle kritischen Design-Probleme:
 * - Hintergrundbild korrekt anzeigen
 * - Spacing unter Login entfernen
 * - Footer weniger transparent, abgerundete Ecken
 * - Highscore Farbgebung anpassen
 * - Layout-Fixes (Sidebars bleiben oben, brechen nicht um)
 * - Alle festen Größen → relativ
 */

/* ============================================
   HINTERGRUNDBILD FIX - ALWAYS VISIBLE, STRETCHED
   ============================================ */
html {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #2a2a2a;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #2a2a2a !important;
    background-image: url('/images/body-bg.jpg') !important;
    background-attachment: fixed !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    -webkit-background-size: cover !important;
    -moz-background-size: cover !important;
    -o-background-size: cover !important;
}

/* Fallback wenn Bild nicht lädt */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    z-index: -2;
    pointer-events: none;
}

/* ============================================
   LOGIN SPACING FIX - Großes unnötiges Spacing entfernen
   ============================================ */
.login-container,
#login-section,
.home-login-section {
    margin-bottom: 0 !important;
    padding-bottom: 0.25rem !important;
}

/* Unnötiges Spacing unter Login entfernen */
.login-container + div,
.login-container + br,
#login-section + div,
#login-section + br,
home.php .row:first-of-type {
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 0.5rem !important;
}

/* Home.php spezifische Login-Fixes */
.container > .row:first-child {
    margin-bottom: 0.5rem !important;
}

.container > .row h3 {
    margin-top: 0 !important;
    margin-bottom: 0.75rem !important;
}

/* Form row spacing fixes */
.form-row {
    margin-bottom: 0 !important;
}

/* ============================================
   FOOTER FIXES - Weniger transparent + Leicht abgerundete Ecken
   ============================================ */
.site-footer,
footer,
.footer,
div[style*="background-color: #726B6C"]:last-child {
    background: linear-gradient(135deg, #021B40 0%, #031d45 50%, #021B40 100%) !important; /* Wie Sidebar */
    border-top-left-radius: 12px !important; /* Leicht abgerundet */
    border-top-right-radius: 12px !important; /* Leicht abgerundet */
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    padding: 1.25rem 1.5rem !important;
    margin-top: 2rem !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
    border-top: 2px solid #cc520d; /* Orange Border wie im Styleguide */
    border: 2px solid #cc520d;
    border-bottom: none;
}

.site-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: #fff;
    padding: 1rem;
}

.site-footer-url,
.site-footer-content .site-footer-url {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.site-footer a {
    color: #ff9900;
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-footer a:hover {
    color: #ffb347;
    text-decoration: underline;
}

/* ============================================
   LAYOUT FIX - Grid System für Sidebars (Fix Umbruch)
   ============================================ */
.site-content {
    display: grid !important;
    grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr) minmax(12rem, 15rem) !important;
    grid-template-areas: "left main right" !important;
    gap: 1rem !important;
    max-width: 95rem !important;
    margin: 0 auto !important;
    padding: 1rem !important;
    min-height: calc(100vh - 20rem);
    align-items: start !important; /* Wichtig: Verhindert Umbruch */
    width: 100%;
}

.site-content-left {
    grid-area: left !important;
    min-width: 0 !important;
    width: 100%;
    overflow: visible;
}

.site-content-main {
    grid-area: main !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100%;
    overflow-x: hidden;
}

.site-content-right {
    grid-area: right !important;
    min-width: 0 !important;
    width: 100%;
    overflow: visible;
}

/* Sticky Sidebars nur auf Desktop */
@media (min-width: 1200px) {
    .site-content-left,
    .site-content-right {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        overflow-x: hidden;
        align-self: start;
    }
    
    /* Custom scrollbar */
    .site-content-left::-webkit-scrollbar,
    .site-content-right::-webkit-scrollbar {
        width: 6px;
    }
    
    .site-content-left::-webkit-scrollbar-track,
    .site-content-right::-webkit-scrollbar-track {
        background: rgba(42, 42, 42, 0.5);
    }
    
    .site-content-left::-webkit-scrollbar-thumb,
    .site-content-right::-webkit-scrollbar-thumb {
        background: rgba(255, 102, 0, 0.5);
        border-radius: 3px;
    }
    
    .site-content-left::-webkit-scrollbar-thumb:hover,
    .site-content-right::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 102, 0, 0.7);
    }
}

/* ============================================
   HIGHSCORE FARBGEBUNG FIX - Anpassung an Styleguide
   ============================================ */
.highscore-container,
#highscore-table,
.highscore-wrapper,
.highscore-modern {
    background: linear-gradient(135deg, #726B6C 0%, #595959 100%) !important;
    border: 2px solid #ff6600 !important; /* Orange Border */
    border-radius: 8px !important;
    padding: 1.5rem !important;
    color: #BAB3B4 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.highscore-container h1,
.highscore-container h2,
.highscore-wrapper h1,
.highscore-wrapper h2 {
    font-weight: bold !important;
    background: linear-gradient(135deg, #ff6600 0%, #ff9900 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    border-bottom: 2px dashed #328727 !important; /* Gestricheltes Grün */
    padding-bottom: 0.75rem !important;
    margin-bottom: 1.5rem !important;
}

.highscore-table,
.highscore-table table {
    width: 100% !important;
    border-collapse: collapse !important;
    background: transparent !important;
}

.highscore-table th {
    background: linear-gradient(90deg, #8B7D7D 0%, #726B6C 100%) !important;
    color: #fff !important;
    padding: 0.75rem 1rem !important;
    text-align: left !important;
    font-weight: bold !important;
    border-bottom: 2px solid #ff6600 !important;
}

.highscore-table td {
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid #595959 !important;
    color: #BAB3B4 !important;
}

.highscore-table tr:hover {
    background: rgba(255, 102, 0, 0.1) !important;
}

.highscore-table tr.highlight,
.highscore-table tr.current-user {
    background: linear-gradient(90deg, rgba(255, 102, 0, 0.2) 0%, rgba(255, 153, 0, 0.1) 100%) !important;
    border-left: 4px solid #ff6600 !important;
    font-weight: bold !important;
}

/* Rank badges */
.highscore-rank,
.rank-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff6600 0%, #ff9900 100%);
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    min-width: 2rem;
    text-align: center;
}

/* Top 3 special styling */
.highscore-table tr:nth-child(1) .highscore-rank,
.rank-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000;
}

.highscore-table tr:nth-child(2) .highscore-rank,
.rank-2 {
    background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
    color: #000;
}

.highscore-table tr:nth-child(3) .highscore-rank,
.rank-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
    color: #fff;
}

.highscore-table thead {
    background: linear-gradient(135deg, #726B6C 0%, #595959 100%) !important;
}

.highscore-table thead th {
    color: #fff !important;
    padding: 0.75rem !important;
    border-bottom: 2px solid #ff6600 !important;
    text-align: left !important;
}

.highscore-table tbody tr {
    background: rgba(114, 107, 108, 0.5) !important;
    transition: background 0.3s ease;
}

.highscore-table tbody tr:hover {
    background: rgba(139, 125, 125, 0.7) !important;
}

.highscore-table tbody tr.kg-highlight,
.highscore-table tbody tr.own-user {
    border-left: 4px solid #ff6600 !important;
    background: rgba(255, 102, 0, 0.2) !important;
}

.highscore-table tbody td {
    padding: 0.5rem 0.75rem !important;
    color: #BAB3B4 !important;
    border-bottom: 1px solid #595959 !important;
}

/* ============================================
   RELATIVE SIZES - Keine festen Pixel-Werte
   ============================================ */
/* Container */
.container,
.kg-container {
    max-width: 100% !important;
    width: 100% !important;
    padding: 1rem !important;
}

/* Tabellen */
table {
    width: 100% !important;
    max-width: 100% !important;
}

/* Buttons */
.btn,
button,
input[type="submit"],
input[type="button"] {
    padding: 0.5rem 1rem !important;
    font-size: 1rem !important;
    min-height: 2.5rem !important;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.5rem !important;
    font-size: 1rem !important;
}

/* ============================================
   "BUGS" TEXT-ÜBERLAUF FIX
   ============================================ */
.sidebar-items-left div,
.sidebar-items-right div,
.menu-content {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: nowrap !important;
    padding: 0.25rem 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
}

.sidebar-items-left div img,
.sidebar-items-right div img {
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

.sidebar-items-left a,
.sidebar-items-right a {
    display: inline !important;
    max-width: 100% !important;
    word-break: break-word !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.sidebar-notification {
    display: inline !important;
    margin-left: auto !important;
}

/* Spezifischer Fix für "Bugs" Link */
a[href*="bugs"],
a[href*="Bugs"] {
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet: Sidebars unter Content */
@media (max-width: 992px) {
    .site-content {
        grid-template-columns: 1fr !important;
        grid-template-areas: 
            "main"
            "left"
            "right" !important;
    }
    
    .site-content-left,
    .site-content-right {
        position: static !important;
        max-height: none !important;
    }
}

/* Mobile: Alles einspaltiger, größere Touch-Targets */
@media (max-width: 768px) {
    body {
        font-size: 0.9rem !important;
    }
    
    .site-content {
        padding: 0.5rem !important;
        gap: 0.5rem !important;
    }
    
    .site-footer {
        padding: 0.75rem 1rem !important;
        border-radius: 6px 6px 0 0 !important;
    }
    
    .site-footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    /* Buttons Touch-optimiert */
    .btn,
    button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important; /* iOS/Android Empfehlung */
        font-size: 1.1rem !important;
    }
}

/* Sehr kleine Mobilgeräte */
@media (max-width: 480px) {
    body {
        font-size: 0.85rem !important;
    }
    
    .highscore-container h2,
    .highscore-wrapper h2 {
        font-size: 1.25rem !important;
    }
    
    .highscore-table thead th,
    .highscore-table tbody td {
        padding: 0.35rem !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white !important;
        background-image: none !important;
    }
    
    .site-content-left,
    .site-content-right,
    .site-footer {
        display: none !important;
    }
    
    .site-content {
        display: block !important;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
/* Focus States */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #ff6600 !important;
    outline-offset: 2px !important;
}

/* Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    background: #ff6600;
    color: white;
    padding: 0.5rem 1rem;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    body {
        background: #000 !important;
    }
    
    .highscore-container,
    .kg-container {
        border-width: 3px !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   BUGS TEXT OVERFLOW FIX (Eingeloggt)
   ============================================ */
/* Fix für "Bugs" Text der in andere Felder überläuft */
.sidebar .bluebg,
.sidebar-items-left div,
.sidebar-items-right div,
.menu-div,
.sidebar-content {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Spezifischer Fix für Sidebar Links */
.sidebar-items-left a,
.sidebar-items-right a {
    display: block !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
}

/* Bug-Meldung Container */
.sidebar .bugs-container,
.sidebar [class*="bug"] {
    padding: 0.5rem !important;
    margin: 0.25rem 0 !important;
    overflow: hidden !important;
}

/* Sidebar Text Wrapping */
.sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

.sidebar table {
    table-layout: fixed !important;
    width: 100% !important;
}

.sidebar td {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* ============================================
   GOOGLE ADS OPTIMIZATION
   ============================================ */
/* Ads Container mit besserer Platzierung */
.ad-container,
.google-ads,
[id*="google_ads"],
[class*="adsbygoogle"] {
    margin: 1.5rem auto !important;
    max-width: 100% !important;
    overflow: hidden !important;
    clear: both !important;
    display: block !important;
}

/* Ads nicht zwischen wichtigen Inhalten */
.ad-container + .ad-container {
    margin-top: 3rem !important;
}

/* Responsive Ads */
@media (max-width: 768px) {
    .ad-container,
    .google-ads {
        margin: 1rem auto !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .site-footer,
    .ad-container,
    .google-ads,
    .sidebar-items-left,
    .sidebar-items-right {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .site-content {
        grid-template-columns: 1fr !important;
        grid-template-areas: "main" !important;
    }
}
