/* --- Color Palettes --- */

/* Light Theme (Default) */
html,
html[data-theme="light"] {
  --btc: #f7931a;
  --bch: #8dc351;
  --eth: #3c3c3d;
  --doge: #c2a633;
  
  --page-bg: #f8f9fa;
  --card-bg: #ffffff;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-light: #f8f9fa; /* For dark buttons */
  --nav-text: rgba(255, 255, 255, 0.55); /* Navbar link color */
  --nav-text-active: #ffffff; /* Navbar active link color */
  --border-color: #dee2e6;
  --primary-accent: #0d6efd;
  --form-bg: #ffffff;
  --hover-bg: #f8f9fa;
  --nav-bg: #212529; /* Default dark navbar */
  
  /* --- NEW --- */
  --shortlink-card-bg: #ffffff;
}

/* Dark Theme */
html[data-theme="dark"] {
  --page-bg: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f8f9fa;
  --text-secondary: #94a3b8;
  --text-light: #f8f9fa;
  --nav-text: rgba(255, 255, 255, 0.55);
  --nav-text-active: #ffffff;
  --border-color: #334155;
  --primary-accent: #3b82f6;
  --form-bg: #0f172a;
  --hover-bg: #334155; /* Changed hover to be slightly lighter than card bg */
  --nav-bg: #1e293b; /* Dark theme navbar */
  
  /* --- NEW --- */
  --shortlink-card-bg: #1e293b;
}

/* --- Global Styles (Using new vars) --- */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar {
    background-color: var(--nav-bg) !important;
}

/* --- Header Nav Link Styling --- */
/* (Replaces navbar-dark) */
.navbar .navbar-brand {
    color: var(--nav-text-active);
}
.navbar .navbar-nav .nav-link {
    color: var(--nav-text);
}
.navbar .navbar-nav .nav-link.active,
.navbar .navbar-nav .nav-link:hover {
    color: var(--nav-text-active);
}

/* * Overrides Bootstrap's default black hamburger icon
 */
.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.1);
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}
/* --- End of Header Styling --- */


.faucet-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    margin-top: 5vh;
}

.faucet-card h2,
.faucet-card .form-label {
    color: var(--text-primary);
}

/* --- Form Controls --- */
.form-control,
.form-select {
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
}
.form-control::placeholder {
    color: var(--text-secondary);
}
.form-control:focus,
.form-select:focus {
    background-color: var(--form-bg);
    border-color: var(--primary-accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

/* --- Status Box --- */
#statusBox {
    background-color: var(--page-bg) !important; /* Use page bg for contrast */
    border: 1px dashed var(--border-color) !important;
}
#statusBox h5 {
    color: var(--text-primary);
}
#statusBox .text-muted {
    color: var(--text-secondary) !important;
}

/* --- Coin Selector --- */
.coin-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.coin-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.coin-option .coin-label {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  height: 100%;
}
.coin-option .coin-label .text-muted {
    color: var(--text-secondary) !important;
}
.coin-option .coin-label:hover {
  background-color: var(--hover-bg);
}
.coin-icon {
  margin-right: 0.75rem;
  font-size: 1.5rem;
  width: 24px;
  text-align: center;
}
.coin-icon img {
  width: 24px;
  height: 24px;
}

/* Checked coin styles */
#coin_btc:checked + .coin-label {
  background-color: var(--btc); color: #fff; border-color: var(--btc);
}
#coin_bch:checked + .coin-label {
  background-color: var(--bch); color: #fff; border-color: var(--bch);
}
#coin_eth:checked + .coin-label {
  background-color: var(--eth); color: #fff; border-color: var(--eth);
}
#coin_doge:checked + .coin-label {
  background-color: var(--doge); color: #fff; border-color: var(--doge);
}
#coin_btc:checked + .coin-label .text-muted,
#coin_bch:checked + .coin-label .text-muted,
#coin_eth:checked + .coin-label .text-muted,
#coin_doge:checked + .coin-label .text-muted {
    color: #f1f1f1 !important;
}

/* --- Claim Button --- */
.btn-primary {
    padding: 12px;
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--text-light);
    background-color: var(--primary-accent);
    border-color: var(--primary-accent);
    transition: all 0.2s ease-in-out;
}
/* Coin-specific classes */
.btn-claim-btc { background-color: var(--btc) !important; border-color: var(--btc) !important; }
.btn-claim-bch { background-color: var(--bch) !important; border-color: var(--bch) !important; }
.btn-claim-eth { background-color: var(--eth) !important; border-color: var(--eth) !important; }
.btn-claim-doge { background-color: var(--doge) !important; border-color: var(--doge) !important; }

.btn-primary:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    color: var(--text-light) !important;
}
.btn-primary:disabled {
    background-color: var(--border-color) !important;
    border-color: var(--border-color) !important;
}

/* --- FOOTER FIX --- */
footer .text-muted {
    color: var(--text-secondary) !important;
}
footer .nav-link {
    color: var(--text-secondary) !important;
}
footer .nav-link:hover {
    color: var(--primary-accent) !important;
}

/* --- Theme Toggle Button --- */
/* **** THIS BLOCK IS RESTORED AND FIXED **** */
.navbar .navbar-nav .theme-toggle {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    line-height: 1; /* Helps vertical alignment */
}

/* Directly target the icons inside the button and make them white */
.navbar .navbar-nav .theme-toggle i {
    color: var(--nav-text-active) !important; /* nav-text-active is #ffffff */
    transition: color 0.2s ease;
}

/* Make the button have a background on hover/focus, not the icon */
.navbar .navbar-nav .theme-toggle:hover,
.navbar .navbar-nav .theme-toggle:focus {
    background-color: rgba(255, 255, 255, 0.1);
    outline: none; /* Remove focus ring */
    box-shadow: none; /* Remove focus shadow */
}
/* **** END OF FIXED BLOCK **** */


/*
 * In light mode, hide the sun (so the moon shows).
 * In dark mode, hide the moon (so the sun shows).
 */
/* **** THIS BLOCK IS RESTORED **** */
html[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}
html[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}
/* **** END OF RESTORED BLOCK **** */


/* --- NEW: RECENT CLAIMS TABLE STYLES --- */

.claims-table-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 2rem;
}

.coin-icon-small {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
}

.recent-claims-table {
    color: var(--text-primary);
    border-color: var(--border-color);
    /* Remove default table striping */
    --bs-table-striped-bg: transparent; 
    background-color: transparent !important; /* Force table to inherit card-bg */
}

.recent-claims-table thead th {
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

/* --- RULE FOR WHITE HEADER IN DARK MODE HAS BEEN REMOVED --- */

.recent-claims-table tbody tr {
    transition: background-color 0.2s ease;
}

.recent-claims-table tbody tr:hover {
    background-color: var(--hover-bg);
}

.recent-claims-table td,
.recent-claims-table th {
    border-color: var(--border-color);
    vertical-align: middle;
}

/* Light/Dark mode specific table head */
html[data-theme="light"] .recent-claims-table {
    border-color: #e9ecef;
}
html[data-theme="light"] .recent-claims-table thead th {
    border-color: #dee2e6;
}
html[data-theme="light"] .recent-claims-table td,
html[data-theme="light"] .recent-claims-table th {
    border-color: #e9ecef;
}

/* Fix for dark mode table striping */
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--text-primary);
}

/* --- FIX: Force dark mode table colors --- */
html[data-theme="dark"] .recent-claims-table,
html[data-theme="dark"] .recent-claims-table th,
html[data-theme="dark"] .recent-claims-table td {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .recent-claims-table thead th {
    color: var(--text-secondary) !important; /* Keep header text slightly muted */
}

html[data-theme="dark"] .recent-claims-table tbody tr:hover {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}
/* --- END FIX --- */


/* --- NEW: RESPONSIVE IMPROVEMENT --- */
@media (max-width: 576px) {
  /* Stacks the coin selector to 1 column on small screens */
  .coin-selector {
    grid-template-columns: 1fr;
  }
}

/* --- ADDED: RESPONSIVE TABLE STYLES --- */
@media (max-width: 767px) {
    /* Hide the desktop header */
    .recent-claims-table thead {
        display: none;
    }

    /* Make the table, body, and rows full-width blocks */
    .recent-claims-table,
    .recent-claims-table tbody,
    .recent-claims-table tr, /* --- FIX: Corrected typo here --- */
    .recent-claims-table td {
        display: block;
        width: 100%;
    }

    /* Style each row like a card */
    .recent-claims-table tr {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 1rem;
    }
    
    /* Remove row borders, add padding */
    .recent-claims-table td {
        border: none;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        padding-top: 1rem;
        padding-bottom: 1rem;
        text-align: right; /* Align content to the right */
        position: relative;
    }

    /* Add the data-label as a pseudo-element */
    .recent-claims-table td::before {
        content: attr(data-label); /* Get text from data-label attribute */
        position: absolute;
        left: 1.5rem; /* Align to the left */
        font-weight: 600; /* Make label bold */
        color: var(--text-primary); /* Use primary text color */
        text-align: left;
    }

    /* Style the first cell as the "header" of the card */
    .recent-claims-table tr td:first-child {
        border-radius: 8px 8px 0 0;
        font-weight: 600; /* Make the wallet address bold */
    }

    /* Style the last cell */
    .recent-claims-table tr td:last-child {
        border-radius: 0 0 8px 8px;
    }

    /* Special fix for coin icon/text alignment */
    .recent-claims-table td[data-label="Coin"] {
        /* This ensures the icon and text stay together */
        display: flex;
        justify-content: flex-end; /* Aligns content (icon+text) to the right */
        align-items: center;
    }
    .recent-claims-table td[data-label="Coin"]::before {
        /* Fixes label alignment for the flex container */
        position: absolute;
        left: 1.5rem;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Adjust padding on the main card for mobile */
    .claims-table-card {
        padding: 1rem;
    }
}


/* --- NEW: SHORTLINK STYLES --- */
.shortlink-list-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 2rem;
}

.shortlink-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.shortlink-card {
    background-color: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.shortlink-card:hover {
    background-color: var(--hover-bg);
}

.shortlink-info strong {
    color: var(--text-primary);
}

.shortlink-action {
    display: flex;
    align-items: center;
}

.shortlink-claims {
    margin-right: 1rem;
    font-size: 0.9rem;
}

/* Responsive shortlink list (Desktop Grid) */
@media (min-width: 768px) {
    .shortlink-list {
        grid-template-columns: 1fr 1fr;
    }
}

/* Responsive card content (Small Mobile) */
@media (max-width: 480px) {
    .shortlink-card {
        flex-direction: column; /* Stack info and action vertically */
        align-items: flex-start; /* Align all to the left */
        gap: 0.5rem; /* Add some space between the stacked items */
    }
    .shortlink-action {
        width: 100%; /* Make the action block full width */
        display: flex;
        justify-content: space-between; /* Keep (0/1) and Visit button apart */
        align-items: center;
    }
}


/* --- *** NEW DARK MODE FIXES *** --- */

/* 1. Fixes browser autofill on dark mode (white background bug) */
html[data-theme="dark"] .form-control {
    /* Force dark background and light text, fixes autofill */
    box-shadow: inset 0 0 0 50px var(--form-bg) !important;
    color: var(--text-primary) !important;
}

/* 2. Fixes the (1/100) text color in dark mode */
html[data-theme="dark"] .shortlink-claims.text-muted {
    color: var(--text-secondary) !important;
}
/* --- *** END NEW FIXES *** --- */


/* Fix for icons on verify page */
.bi-check-circle-fill, .bi-x-circle-fill {
    display: block;
    margin-left: auto;
    margin-right: auto;
}


/* --- *** NEW AD BANNER STYLES *** --- */

/* Main Wrapper for Side Ads */
.main-content-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    /* Max width = 160(L) + 20(gap) + 1140 (xl container) + 20(gap) + 160(R) = 1500 */
    max-width: 1500px; 
    margin: 0 auto;
    position: relative;
}

/* Side Banners (160x600) */
.ad-sidebar {
    width: 160px;
    height: 600px;
    flex-shrink: 0;
    margin-top: 5vh; /* Aligns with faucet card margin-top */
}

.ad-sidebar-left {
    margin-right: 20px;
}

.ad-sidebar-right {
    margin-left: 20px;
}

/* This is the main <div class="container"> on the home page */
#home-container {
    width: 100%;
    /* The .container class already sets max-width, which is what we want */
}

/* Center Banners (300x100, 300x250) */
.ad-banner-center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    /* Let the ad content define the size */
}

.ad-banner-top {
    margin-bottom: 1.5rem;
}

/* Responsive: Hide side banners on smaller desktops/tablets */
/* 160(L) + 20(gap) + 992 (lg container) + 20(gap) + 160(R) = 1352. */
@media (max-width: 1399.98px) {
    .ad-sidebar {
        display: none;
    }
}

/* Responsive: Ensure center banners don't overflow on tiny screens */
@media (max-width: 360px) {
    .ad-banner-recaptcha,
    .ad-banner-top,
    .ad-banner-mid {
        max-width: 100%;
        overflow: hidden; /* Prevents ad from breaking layout */
    }
}

/* --- *** NEW: FOOTER RESPONSIVE FIX *** --- */
@media (max-width: 576px) {
    footer .d-flex {
        text-align: center; /* Center-aligns the copyright text */
    }
    
    .footer-nav-links {
        justify-content: center !important; /* Forces nav links to center */
        width: 100%;
    }
}