/* =======================================================
   1. Variablendefinition (Light & Dark Mode)
   ======================================================= */
:root {
    /* Farben (Light Mode) - HOHER KONTRAST */
    --primary: #5a6268; /* Grauer Akzent */
    --primary-light: #d0d5db; /* Helleres Grau für Box-Shadow */
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #cc0000; /* Kräftiges Rot */
    --warning: #ffc107;

    --bg-body: #e9ecef; /* Heller, aber kontrastreich (Grau) */
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-tile-hover: #f1f3f5; /* Sehr heller Hover-Effekt */

    --text-main: #212529; /* Sehr dunkler Text (Fast Schwarz) */
    --text-muted: #495057; /* Dunklere Muted-Farbe */
    --text-error: #cc0000;

    --border-color: #adb5bd; /* Dunklere, deutlichere Border */
    --border-card: rgba(0, 0, 0, 0.15); /* Deutlichere Kartengrenze */
    --shadow-card: 0 6px 15px rgba(0, 0, 0, 0.1); /* Stärkerer Schatten */
    
    --border-radius: 6px;
}

/* Dark Mode Umschaltung (UNVERÄNDERT) */
html.dark-mode {
    --primary: #94a3b8;
    --primary-light: #3f4a56;
    --danger: #ff4d4d;
    --success: #3ac35d;

    --bg-body: #212529;
    --bg-card: #343a40;
    --bg-input: #2c3034;
    --bg-tile-hover: #495057;
    
    --text-main: #e9ecef;
    --text-muted: #adb5bd;
    --text-error: #ff4d4d;

    --border-color: #495057;
    --border-card: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 4px 10px rgba(0, 0, 0, 0.5);
}


/* =======================================================
   2. Allgemeine Formatierung (Reset, Body)
   ======================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.text-primary-link {
    color: var(--primary);
}
.text-primary-link:hover {
    color: var(--primary);
}

.text-muted-small {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.text-price {
    font-weight: bold;
}

/* =======================================================
   3. Navbar und Header
   ======================================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1rem;
}

.nav-user strong {
    font-weight: bold;
    color: var(--primary);
}

/* =======================================================
   4. Buttons und Badges
   ======================================================= */
.btn {
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--bg-card);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary);
    filter: brightness(1.1);
    text-decoration: none;
}

.btn-danger {
    background-color: var(--danger);
    color: var(--bg-card);
    border-color: var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    filter: brightness(1.1);
    text-decoration: none;
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-outline:hover {
    background-color: var(--bg-tile-hover);
    text-decoration: none;
}

.btn-block {
    width: 100%;
    display: block;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    border-radius: var(--border-radius);
    margin-left: 8px;
}

/* =======================================================
   5. Formulare und Eingabe
   ======================================================= */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-input);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.error-text {
    display: block;
    color: var(--text-error);
    font-size: 0.85rem;
    margin-top: 5px;
}


/* =======================================================
   6. Card und Main Layout
   ======================================================= */

.main-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.card {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-card);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.5rem;
    color: var(--text-main);
}

.card-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

/* Auth Pages (Login/Register) Zentrierung */
.center-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 30px 20px;
    background-color: var(--bg-body);
}

.auth-card {
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.auth-card h1 {
    font-size: 2rem;
    margin-bottom: 5px;
    color: var(--primary);
}

.auth-logo {
    display: block; /* Für die Zentrierung */
    margin: 0 auto 20px; /* Vertikale Zentrierung und Abstand nach unten */
    max-width: 150px; /* Maximale Breite festlegen */
    height: auto; /* Seitenverhältnis beibehalten */
}

.auth-card .card-title {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}


/* =======================================================
   7. Produkt-Tiles (Dashboard/Suche)
   ======================================================= */
.grid-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-tile, .top-change-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-card);
    color: var(--text-main);
    text-decoration: none;
    transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s;
    height: 100%;
}

.product-tile:hover, .top-change-tile:hover {
    background-color: var(--bg-tile-hover);
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.product-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
    line-height: 1.3;
}

.product-pzn {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
}

/* Spezielles Styling für Top-Reduktionen */
.top-change-tile {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start; 
}

.top-change-tile > div:first-child {
    max-width: 60%;
}
.top-change-tile > div:last-child {
    text-align: right;
    min-width: 40%;
}

.change-percent {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--danger);
    display: block;
    margin-bottom: 5px;
}

.old-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.price-compare {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-end;
}

/* =======================================================
   8. Produkt-Detail-Seite (product_detail.php)
   ======================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 250px;
    gap: 20px;
    margin-top: 20px;
}

.product-details {
    /* Hauptinhalt, nimmt den Rest des Platzes ein */
}

.side-card {
    /* Seitenleiste, feste Breite */
}

/* Tabelle für Preisvergleich */
.price-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.95rem;
}

.price-table th, .price-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.price-table th {
    background-color: var(--bg-tile-hover);
    font-weight: 600;
    color: var(--text-main);
    border-top: 1px solid var(--border-color);
}

.price-table tr:hover {
    background-color: var(--bg-tile-hover);
}

/* Status Message / Toast Notification */
.status-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: var(--border-radius);
    font-weight: bold;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #fff;
    transform: translate(-50%, -100%); 
}

.status-message.success {
    background-color: var(--success);
}
.status-message.error {
    background-color: var(--danger);
}
.status-message.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* =======================================================
   9. Responsive Anpassungen
   ======================================================= */
@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .side-card {
        order: -1;
    }
    .side-card .card {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    
    .nav-user {
        margin-top: 10px;
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }

    .nav-user span {
        display: none;
    }

    .main-container {
        margin: 20px auto;
        padding: 0 10px;
    }
    
    /* Suchformular Anpassung */
    .card form {
        flex-direction: column;
    }

    .card form a.btn-outline {
        margin-top: 5px;
    }

    .top-change-tile {
        flex-direction: column;
        align-items: stretch;
    }

    .top-change-tile > div:first-child {
        max-width: 100%;
    }
    
    .top-change-tile > div:last-child {
        text-align: left !important;
        margin-top: 10px !important;
        padding-top: 10px;
        border-top: 1px solid var(--border-card);
        min-width: unset;
    }
    .price-compare {
        justify-content: flex-start;
    }
}