/* =======================
   GLOBAL MODAL CONTENT RESET
   ======================= */
body, html, .modal, .modal *, .modal-content, .modal-content *, 
#loginModal, #loginModal *, 
.modal-content::before, .modal-content::after {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  background-clip: padding-box !important;
  border-radius: 0 !important;
}

/* Only apply background globally for modal-content (not overlay!) */
.modal-content, .modal-content *, .modal-content::before, .modal-content::after {
  background: #f9f9f9 !important;
}
.modal-content::before,
.modal-content::after {
  display: none !important;
  content: none !important;
}

/* =======================
   NATURAL INPUT FIELD STYLE FOR MODALS
   ======================= */
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content input[type="email"] {
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    padding: 10px 12px;
    box-sizing: border-box;
    width: 100%;
    font-size: 1em;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none !important;
    margin-bottom: 16px;
}
.modal-content input[type="text"]:focus,
.modal-content input[type="password"]:focus,
.modal-content input[type="email"]:focus {
    border-color: #3399ff !important;
    box-shadow: 0 2px 0 0 #3399ff !important;
}
.modal-content input[type="text"]:not(:focus),
.modal-content input[type="password"]:not(:focus),
.modal-content input[type="email"]:not(:focus) {
    box-shadow: none !important;
}

/* =======================
   MODAL CONTENT & OVERLAY
   ======================= */
.modal,
#loginModal {
    background-color: rgba(0,0,0,0.4) !important;
}
.modal-content {
    background-color: #f9f9f9 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 7% auto !important;
    padding: 24px 32px !important;
    width: 95% !important;
    max-width: 400px !important;
    position: relative !important;
}
.modal-content, .modal-content * {
    border-radius: 0 !important;
}

/* =======================
   PRODUCT LIST STYLES
   ======================= */
.products {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: center;
    margin: 40px auto;
    max-width: 1200px;
}

/* =======================
   PRODUCT CARD STYLES
   ======================= */
.product {
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 30px 20px;
    background: #fafafa;
    width: 45vw; /* Each product card takes about half the viewport width */
    max-width: 500px;
    min-width: 320px;
    text-align: center;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    margin: 0 10px 30px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.product img,
.product-detail img {
    width: 100%;
    max-width: 430px;
    height: 430px;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 20px;
}
.product h2 {
    font-size: 1.8em;
    margin: 10px 0 5px 0;
}
.product p {
    margin: 0 0 15px 0;
    font-size: 1.1em;
}
.product-actions {
    margin-top: 20px;
}
.product-actions a {
    margin-right: 16px;    /* Adds space between links */
    text-decoration: none; /* Makes links cleaner */
    color: #336699;        /* Preferred link color */
    font-weight: bold;     /* Make links bold */
}
.product-actions a:last-child {
    margin-right: 0;       /* No extra space after the last link */
}

/* =======================
   REGISTER/LOGIN BOX STYLES
   ======================= */
.register-topright {
    position: fixed;
    top: 24px;
    right: 32px;
    z-index: 1000;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 12px #aaa;
    padding: 16px 24px;
    min-width: 240px;
    text-align: right;
}
.register-topright label {
    display: block;
    margin-bottom: 8px;
}
.register-topright form {
    margin-bottom: 10px;
}
.register-topright a, .register-topright button {
    display: inline-block;
    margin-left: 10px;
    margin-top: 4px;
    color: #0077cc;
    text-decoration: none;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
}
.register-topright .welcome {
    margin-bottom: 10px;
    display: block;
}

/* =======================
   MODAL STYLES
   ======================= */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto;
    /* background-color overridden above */
}
.close {
    color: #aaa;
    position: absolute; right: 16px; top: 16px;
    font-size: 28px; font-weight: bold; cursor: pointer;
}
.close:hover { color: #333; }

/* =======================
   DARK THEME - Enable by adding 'dark-theme' to <body>
   ======================= */
body.dark-theme {
    background: #191c20 !important;
    color: #e0e2e6 !important;
}
body.dark-theme .modal,
body.dark-theme #loginModal {
    background-color: rgba(0,0,0,0.85) !important;
}
body.dark-theme .modal-content {
    background-color: #23262b !important;
    color: #e0e2e6 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7) !important;
    outline: none !important;
}
body.dark-theme .modal-content input[type="text"],
body.dark-theme .modal-content input[type="password"],
body.dark-theme .modal-content input[type="email"] {
    background: #22252a !important;
    color: #e0e2e6 !important;
    border: 1px solid #444952 !important;
    border-radius: 6px !important;
    padding: 10px 12px;
    box-sizing: border-box;
    width: 100%;
    font-size: 1em;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none !important;
    margin-bottom: 16px;
}
body.dark-theme .modal-content input[type="text"]:focus,
body.dark-theme .modal-content input[type="password"]:focus,
body.dark-theme .modal-content input[type="email"]:focus {
    border-color: #5db0ff !important;
    box-shadow: 0 2px 0 0 #5db0ff !important;
}
body.dark-theme .modal-content input[type="text"]:not(:focus),
body.dark-theme .modal-content input[type="password"]:not(:focus),
body.dark-theme .modal-content input[type="email"]:not(:focus) {
    box-shadow: none !important;
}
body.dark-theme .product {
    background: #23262b !important;
    border: 1px solid #252830 !important;
    color: #e0e2e6 !important;
    box-shadow: 0 2px 16px rgba(0,0,0,0.16);
}
body.dark-theme .product h2,
body.dark-theme .product p {
    color: #e0e2e6 !important;
}
body.dark-theme .product-actions a {
    color: #66b2ff !important;
}
body.dark-theme .register-topright {
    background: #23262b !important;
    color: #e0e2e6 !important;
    box-shadow: 0 2px 12px #111;
}
body.dark-theme .register-topright a,
body.dark-theme .register-topright button {
    color: #5db0ff !important;
}