:root {
    --bg-color: #eef2f6;
    --text-color: #333;
    --header-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --header-text: white;
    --card-bg: #ffffff;
    --card-border: #e0e0e0;
    --card-text: #2c3e50;
    --secondary-text: #666;
    --filter-bg: #ffffff;
    --filter-border: #e0e0e0;
    --filter-text: #555;
    --link-color: #3498db;
    --link-hover: #2980b9;
    --button-bg: #3498db;
    --button-hover: #2980b9;
    --share-bg: #2ecc71;
    --share-hover: #27ae60;
    --delete-bg: #e74c3c;
    --delete-hover: #c0392b;
    --repair-bg: #f39c12;
    --repair-hover: #e67e22;
    --form-bg: #ffffff;
    --form-border: #e0e0e0;
    --label-color: #555;
    --title-bg: #ffffff;
    --title-border: #e0e0e0;
    --title-text: #2c3e50;
    --back-color: #2c3e50;
    --admin-text: #777;
}

body.dark-mode {
    --bg-color: #000;
    --text-color: #fff;
    --header-bg: linear-gradient(135deg, #000 0%, #111 100%);
    --header-text: white;
    --card-bg: #111;
    --card-border: #333;
    --card-text: #fff;
    --secondary-text: #ccc;
    --filter-bg: #111;
    --filter-border: #333;
    --filter-text: #ccc;
    --link-color: #5dade2;
    --link-hover: #3498db;
    --button-bg: #5dade2;
    --button-hover: #3498db;
    --share-bg: #58d68d;
    --share-hover: #2ecc71;
    --delete-bg: #ec7063;
    --delete-hover: #e74c3c;
    --repair-bg: #f7dc6f;
    --repair-hover: #f39c12;
    --form-bg: #111;
    --form-border: #333;
    --label-color: #ccc;
    --title-bg: #111;
    --title-border: #333;
    --title-text: #fff;
    --back-color: #fff;
    --admin-text: #ccc;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
}

header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 999;
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 600;
}

.affiliate-notice {
    margin: 0.5rem 0 0 0;
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

header a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
}

header a:hover {
    color: #ecf0f1;
}

header nav {
    display: flex;
    gap: 1rem;
}

header nav a {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 1.2rem;
    position: relative;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

header nav a:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #000000;
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    margin-top: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 1;
    transition: opacity 0.3s ease;
}

header nav a::after {
    opacity: 0;
    pointer-events: none;
}

.dropdown {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.dropbtn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    margin: 0;
    font-size: 1.2rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropbtn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--header-text);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    align-self: center;
    margin: 0;
}

#dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #34495e;
    min-width: 120px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 10;
    border-radius: 6px;
    top: 100%;
    right: 0;
    margin-top: 0;
}

.dropdown-content a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.icon-text {
    display: none;
}

.mobile-logout {
    display: none;
}

.logout-text {
    display: none;
}

.filter-container {
    padding: 1.5rem 1rem;
    text-align: center;
    background-color: var(--filter-bg);
    border-bottom: 1px solid var(--filter-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-container span {
    font-weight: bold;
    margin-right: 1rem;
    color: var(--filter-text);
}

.filter-container a {
    margin: 0 0.6rem;
    text-decoration: none;
    color: var(--link-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

.filter-container a:hover {
    color: var(--link-hover);
}

.filter-container a.active {
    color: var(--link-hover);
    font-weight: bold;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.product-card a {
    text-decoration: none;
    color: #333;
    text-align: center;
}

.product-card img {
    max-width: 100%;
    width: auto;
    height: 200px; /* Fixed height for images */
    object-fit: contain; /* Ensures image is not stretched */
    border-radius: 4px;
    margin-bottom: 1rem;
    display: inline-block;
}

.product-card h2 {
    font-size: 1.3rem;
    margin-top: 0.5rem;
    margin-bottom: 0.8rem;
    color: var(--card-text);
    text-align: left;
}

.product-stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid #eee;
}



.product-main {
    padding: 1.5rem;
}

.product-detail-card {
    display: flex;
    gap: 2.5rem;
    max-width: 1000px;
    margin: 2rem auto;
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.product-detail-card img {
    max-width: 450px;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.product-detail-card .product-info {
    flex-grow: 1;
}

.product-detail-card h2 {
    font-size: 2rem;
    color: var(--card-text);
    margin-top: 0;
    margin-bottom: 1rem;
}

.product-detail-card p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.product-stats p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--secondary-text);
    text-align: left;
}

.product-stats p::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 5px;
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
}

.product-stats p:first-child::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%233498db"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.52.48 1.2.77 1.96.77 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .24.04.47.09.7L7.04 9.81C6.52 9.33 5.84 9.03 5.08 9.03c-1.1 0-2 .9-2 2s.9 2 2 2c.76 0 1.44-.3 1.96-.77l7.05 4.11c-.05.23-.09.46-.09.7 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"/></svg>');
}

.product-stats p:last-child::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%232ecc71"><path d="M12 4.5C7.5 4.5 3.73 7.61 2.36 12c1.37 4.39 5.14 7.5 9.64 7.5s8.27-3.11 9.64-7.5c-1.37-4.39-5.14-7.5-9.64-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>');
}

.title-container {
    position: relative;
    margin: 0 0 2rem 0;
    color: var(--title-text);
    background-color: var(--title-bg);
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--title-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.back-button {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--back-color);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.back-button:hover {
    opacity: 0.7;
}

.edit-title {
    margin: 0;
    text-align: center;
}

.login-container, .form-container {
    max-width: 450px;
    margin: 3rem auto;
    padding: 2.5rem;
    background-color: var(--form-bg);
    border: 1px solid var(--form-border);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

input[type="url"], input[type="password"], input[type="text"], input[type="number"], textarea, input[type="datetime-local"] {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1.2rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1rem;
}

label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--label-color);
}

button, .buy-button, .share-button {
    display: block;
    width: 100%;
    padding: 0.9rem 1.5rem;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 1.5rem;
    font-size: 1.1rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

button:hover, .buy-button:hover, .share-button:hover {
    background-color: var(--button-hover);
}

.share-button {
    background-color: var(--share-bg);
    margin-top: 1rem;
}

.share-button:hover {
    background-color: var(--share-hover);
}

.admin-product-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
}

.admin-product-item {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 300px;
}

.product-content {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex: 1;
}

.admin-product-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.admin-product-item .product-details {
    flex-grow: 1;
}

.admin-product-item h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--card-text);
}

.admin-product-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--admin-text);
}

.edit-button {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    background-color: var(--button-bg);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 0.8rem;
    margin-bottom: 0.4rem;
    box-sizing: border-box;
    text-align: center;
    font-size: 0.95rem;
    transition: background-color 0.3s ease;
}

.edit-button:hover {
    background-color: var(--button-hover);
}

.delete-button {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    background-color: var(--delete-bg);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 0.4rem;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.delete-button:hover {
    background-color: var(--delete-hover);
}

.repair-button {
    display: block;
    width: 100%;
    padding: 0.4rem 0.8rem;
    background-color: var(--repair-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-size: 0.95rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.repair-button:hover {
    background-color: var(--repair-hover);
}

/* Mobile responsiveness */
@media screen and (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header nav {
        gap: 0.5rem;
    }

    header nav a {
        padding: 0.4rem 0.8rem;
    }

    .filter-container {
        padding: 1rem 0.5rem;
    }

    .filter-container span {
        display: block;
        margin-bottom: 0.5rem;
    }

    .filter-container a {
        margin: 0 0.3rem;
    }

    .product-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .product-card {
        padding: 1rem;
    }

    .product-card img {
        height: 180px;
    }

    .product-card h2 {
        font-size: 1.2rem;
    }

    .product-stats {
        flex-direction: row;
        justify-content: center;
        gap: 0.5rem;
    }

    .product-detail-card {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem;
        margin: 1.5rem auto;
    }

    .product-detail-card img {
        max-width: 100%;
        width: 100%;
    }

    .product-detail-card h2 {
        font-size: 1.8rem;
    }

    .login-container, .form-container {
        margin: 1.5rem auto;
        padding: 1.5rem;
    }

    input[type="url"], input[type="password"], input[type="text"], input[type="number"], textarea, input[type="datetime-local"] {
        padding: 0.7rem;
        margin-bottom: 1rem;
    }

    button, .buy-button, .share-button {
        padding: 0.8rem 1.2rem;
        font-size: 1rem;
        margin-top: 1rem;
    }

    .admin-product-list {
        flex-direction: column;
        padding: 1rem;
    }

    .admin-product-item {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .product-content {
        flex-direction: column;
    }

    .admin-product-item img {
        width: 100%;
        height: auto;
        max-width: 120px;
    }

    .admin-product-item h3 {
        font-size: 1rem;
    }

    .edit-button, .delete-button {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
        margin-top: 0.6rem;
        margin-bottom: 0.3rem;
    }

    .icon-text {
        display: inline;
    }

    .logout-text {
        display: inline;
    }

    .dropbtn {
        justify-content: center;
    }

    .mobile-logout {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.5rem;
        padding: 0.4rem 0.8rem;
        border-radius: 6px;
        font-size: 1.2rem;
        transition: background-color 0.3s ease;
    }

    #dark-mode-toggle {
        padding: 0.4rem 0.8rem;
        justify-content: flex-start;
    }

    header nav a::after {
        display: none;
    }

    .dropdown {
        display: none;
    }
}

@media screen and (max-width: 600px) {
    header h1 {
        font-size: 1.5rem;
    }

    header nav {
        flex-direction: column;
        gap: 0.25rem;
    }

    header nav a {
        padding: 0.4rem 0.8rem;
        justify-content: flex-start;
    }

    header nav a {
        text-align: center;
    }

    .filter-container a {
        display: block;
        margin: 0.5rem 0;
    }

    .product-grid {
        padding: 0.8rem;
    }

    .product-card {
        padding: 0.8rem;
    }

    .product-detail-card {
        padding: 1rem;
        margin: 1rem auto;
    }

    .login-container, .form-container {
        margin: 1rem auto;
        padding: 1rem;
    }
}
