/* Reset & Base */
:root {
    /* Default: Dark Mode (Fallback) */
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-bg: #1e1e1e;
    --header-title: #ffffff;
    --header-desc: #b0b0b0;
    --card-bg: #1e1e1e;
    --card-shadow: rgba(0,0,0,0.5);
    --card-title: #ffffff;
    --card-desc: #b0b0b0;
    --price-color: #ff6b6b;
    --btn-buy-bg: #27ae60;
    --btn-buy-hover: #219150;
    --info-bg: #2c3e50; /* Keep info cards distinct */
    --info-text: #ffffff;
    --footer-bg: #0a0a0a;
    --footer-text: #ecf0f1;
    --divider-line: #444;
    --divider-text-bg: #121212;
    --divider-text-color: #888;
    --modal-bg: #1e1e1e;
    --modal-text: #e0e0e0;
    --input-bg: #2c2c2c;
    --input-border: #444;
    --input-text: #fff;
}

body.light-mode {
    /* Light Mode Overrides */
    --bg-color: #f4f4f9;
    --text-color: #333;
    --header-bg: #fff;
    --header-title: #2c3e50;
    --header-desc: #7f8c8d;
    --card-bg: #fff;
    --card-shadow: rgba(0,0,0,0.1);
    --card-title: #2c3e50;
    --card-desc: #666;
    --price-color: #e74c3c;
    --btn-buy-bg: #27ae60;
    --btn-buy-hover: #219150;
    --info-bg: #34495e;
    --info-text: #ffffff;
    --footer-bg: #2c3e50;
    --footer-text: #ecf0f1;
    --divider-line: #ddd;
    --divider-text-bg: #f4f4f9;
    --divider-text-color: #999;
    --modal-bg: #fefefe;
    --modal-text: #333;
    --input-bg: #fff;
    --input-border: #ddd;
    --input-text: #333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth Theme Transition */
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    background-color: var(--header-bg);
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    margin-bottom: 40px;
    position: relative; /* For positioning the toggle */
}

header h1 {
    font-size: 2.5rem;
    color: var(--header-title);
    margin-bottom: 10px;
}

header p {
    color: var(--header-desc);
    font-size: 1.1rem;
}

/* Theme Toggle Button */
.theme-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background: var(--text-color);
    color: var(--header-bg);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

/* Grid System */
.grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-bottom: 50px;
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile Header Adjustment */
@media (max-width: 600px) {
    header {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-top: 20px;
    }
    
    .theme-btn {
        position: static;
        align-self: flex-end;
        margin-bottom: 15px;
        margin-right: 10px; /* Slight offset from edge */
    }
}

/* Card Style */
.card, .info-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover, .info-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.card-img-container {
    width: 100%;
    aspect-ratio: 16 / 9; /* Enforce 16:9 Aspect Ratio */
    background-color: #777; /* Neutral grey for placeholder */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--card-title);
}

.card-desc {
    font-size: 0.95rem;
    color: var(--card-desc);
    margin-bottom: 15px;
    line-height: 1.5;
    flex-grow: 1;
    white-space: pre-wrap; /* Support multi-line descriptions */
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--divider-line);
}

.price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--price-color);
}

.btn-buy {
    background-color: var(--btn-buy-bg);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.btn-buy:hover {
    background-color: var(--btn-buy-hover);
}

/* Info Section Divider */
.section-divider {
    border-top: 2px dashed var(--divider-line);
    margin: 40px 0;
    position: relative;
    text-align: center;
}

.section-divider span {
    background: var(--divider-text-bg);
    padding: 0 15px;
    position: relative;
    top: -12px;
    color: var(--divider-text-color);
    font-weight: bold;
    letter-spacing: 1px;
}

/* Info Card Specifics */
.info-card {
    background: var(--info-bg);
    color: var(--info-text);
    padding: 30px;
    text-align: center;
    justify-content: center;
}

.info-card h3 {
    margin-bottom: 15px;
    font-size: 1.4rem;
    color: inherit;
    border-bottom: 2px solid #3498db;
    display: inline-block;
    padding-bottom: 10px;
}

.info-card p {
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.9;
    white-space: pre-wrap; /* Support multi-line info */
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 20px 0;
    margin-top: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

footer p {
    font-weight: bold;
}

footer a {
    color: var(--footer-text);
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s;
}

footer a:hover {
    transform: scale(1.1);
}

footer img, footer svg {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    filter: invert(1); /* Invert GitHub logo to be white in dark mode usually */
}
body.light-mode footer img, body.light-mode footer svg {
    filter: invert(0); /* Black in light mode */
}

/* Modal/Popup */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--modal-bg);
    color: var(--modal-text);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.5);
    position: relative;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    color: var(--card-desc);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: var(--price-color);
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--modal-text);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--modal-text);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--input-text);
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #3498db;
    outline: none;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.input-error {
    animation: shake 0.4s ease-in-out;
    border-color: #e74c3c !important;
}

/* Seller Selection */
.seller-selection {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.btn-seller {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-seller:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}
