@font-face {
    font-family: 'Poppins';
    src: url('Poppins-Regular.ttf');
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin-token {
    animation: spin 6s linear infinite;
}

@keyframes auraPulse {
    0% { box-shadow: 0 0 0 0px rgba(255, 255, 255, 0.4); }
    100% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

.aura-pulse {
    animation: auraPulse 1.5s infinite;
}

@keyframes auraWantPulse {
    0% { box-shadow: 0 0 0 0px rgba(255, 255, 255, 0.8); }
    10% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
    11% { box-shadow: 0 0 0 0px rgba(255, 255, 255, 0); }
    20% { box-shadow: 0 0 0 0px rgba(255, 255, 255, 0.8); }
    30% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

.aura-want {
    animation: auraWantPulse 3s infinite;
}

@keyframes glowPulse {
    0% {
        box-shadow: 0 0 4px 0px var(--pulse-color);
        border-color: var(--pulse-color);
    }
    50% {
        box-shadow: 0 0 12px 2px var(--pulse-color);
        border-color: var(--pulse-color);
    }
    100% {
        box-shadow: 0 0 4px 0px var(--pulse-color);
        border-color: var(--pulse-color);
    }
}

.glow-active {
    animation: glowPulse 1.5s infinite ease-in-out;
}

@keyframes panelEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cardReturn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

body::before {
    content: "";
    position: absolute;
    inset: -50vmax;
    z-index: -1;
    background: conic-gradient(from 20deg, #3E2723, #5D4037, #8D6E63, #388E3C, #0288D1, #3E2723);
    filter: blur(120px) brightness(0.7);
    animation: spin 60s linear infinite;
}

header, footer {
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid black;
    padding: 0.5rem;
    color: white;
    text-align: center;
    border-radius: 20px;
    margin: 1rem;
    flex-shrink: 0;
}

#userBalance {
    font-size: 1.2rem;
    font-weight: bold;
}

#userProfile {
    display: none;
    align-items: center;
    gap: 10px;
}

#userPhoto {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

#signOutBtn {
    font-size: 0.8rem;
    padding: 5px 15px;
    margin-top: 0;
    background-color: #d93025;
}

#signOutBtn:hover {
    background-color: #b31414;
}

header {
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
}

footer {
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

main {
    margin: 1rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
main::-webkit-scrollbar {
    display: none;
}

.main-card {
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid black;
    padding: 1rem;
    color: white;
    text-align: left;
    border-radius: 40px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    position: relative;
    margin-top: 40px;
}

.main-card > div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    flex: 1;
}

/* Apply animation specifically to the algorithm panels */
.main-card > div[id^="panel"] {
    animation: panelEntrance 0.8s cubic-bezier(0.2, 1, 0.3, 1);
    text-align: left;
    align-items: flex-start;
    box-sizing: border-box;
    max-width: calc(100% - 780px);
}

.main-card > div > button {
    align-self: flex-start;
    margin-top: auto;
}

h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

h1 {
    margin: 0;
}

ul {
    padding-left: 1.2rem;
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 100; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: rgba(0, 0, 0, 0.9);
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #444;
    width: 80%; 
    max-width: 400px;
    border-radius: 20px;
    color: white;
    text-align: center;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 10px;
}

.close:hover,
.close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.close-panel {
    position: absolute;
    top: 15px;
    right: 25px;
    cursor: pointer;
    font-size: 24px;
    color: #aaa;
}

.close-panel:hover {
    color: white;
}

input[type="number"], input[type="text"] {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    width: 80%;
    margin-bottom: 10px;
}

button {
    background-color: #1a73e8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:hover {
    background-color: #1557b0;
}

.google-btn {
    background-color: #1a73e8;
    color: white;
    padding: 10px 20px;
    font-size: 1rem;
    gap: 10px;
    margin: 0;
}

.google-btn img {
    width: 18px;
    height: 18px;
    background-color: white;
    border-radius: 50%;
    padding: 2px;
}

.google-btn:hover {
    background-color: #1557b0;
}

#g_id_onload {
    display: none;
}

.cattle-container {
    display: flex;
    width: 100%;
    flex: 1;
    justify-content: center;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px;
    position: relative;
    bottom: 20px;
}

.cattle-card {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.8rem;
    text-align: left;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    transition: all 0.6s cubic-bezier(0.2, 1, 0.3, 1);
    cursor: pointer;
    min-height: 120px;
    animation: cardReturn 0.6s cubic-bezier(0.2, 1, 0.3, 1);
}

.cattle-card:hover {
    transform: translateY(-5px) scale(1.05);
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.cattle-card ul {
    display: none;
}

#dashboard-card {
    animation: none;
    transition: none;
    position: absolute;
    top: 0;
    bottom: 0;
    right: 1rem;
    margin: auto 0;
    height: fit-content;
    width: 755px;
    padding: 0.5rem;
    cursor: default;
    z-index: 10;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

#dashboard-card:hover {
    transform: none;
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: none;
}

.herd-menu-trigger {
    position: absolute;
    top: 50px;
    left: 35px;
    transform: translateX(-50%);
    color: #ccc;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 20;
}

#herdPhotoMenu {
    display: none;
    position: absolute;
    top: 50px;
    left: 60px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 5px;
    z-index: 30;
    width: 120px;
    text-align: left;
}

#userName {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.dashboard-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
}

.dashboard-carousel-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dashboard-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-self: end;
    margin-right: 10px;
}

.dashboard-divider {
    width: 1px;
    height: 90%;
    background-color: #ccc;
}

.dashboard-hotd {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 20px;
}

.dashboard-hotd h3 {
    margin-bottom: 15px;
    position: relative;
    top: -15px;
}

@media (max-width: 1024px) {
    #dashboard-card {
        position: relative;
        width: 100%;
        right: auto;
        top: auto;
        bottom: auto;
        margin: 20px 0;
        flex-direction: column;
        max-height: none;
    }
    .dashboard-main {
        width: 100%;
        justify-content: center;
    }
    .dashboard-divider {
        width: 100%;
        height: 1px;
        margin: 15px 0;
    }
    .dashboard-hotd {
        padding-left: 0;
        width: 100%;
    }
    .main-card > div[id^="panel"] {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        background-color: #222;
        overflow-y: auto;
        height: auto;
        min-height: 100dvh;
    }
    body::before {
        display: none;
    }
    header, footer {
        flex-direction: column;
        gap: 1rem;
        margin: 0.5rem;
    }
    main {
        margin: 0.5rem;
        justify-content: flex-start;
        padding-bottom: 20px;
        overflow: visible;
    }
    .main-card {
        margin-top: 0;
        padding: 0;
        background: transparent;
        border: none;
    }
    #dashboard-card {
        margin: 20px 0 20px 0;
        padding: 10px;
        padding-bottom: 10px;
        min-height: 450px;
        justify-content: space-evenly;
        overflow: visible !important;
    }
    .dashboard-main {
        display: flex;
        justify-content: center;
        position: relative;
        order: 1;
    }
    .dashboard-main > div:first-child {
        display: none;
    }
    .dashboard-controls {
        margin-right: 0;
        position: absolute;
        right: 0;
        top: 50%;
        margin-top: -15px;
    }
    .dashboard-divider {
        display: none;
    }
    .dashboard-hotd {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin-top: 0;
        position: static;
        order: 2;
    }
    .dashboard-hotd h3 {
        margin: 10px 10px 30px 0;
        margin-bottom: 15px;
        position: static;
        font-size: 1.2rem;
        text-align: center;
        padding-bottom: 15px;
    }
    #hotdDisplay {
        margin-bottom: 15px;
    }
    #userName {
        position: static;
        transform: none;
        margin: 10px 0;
    }
    .cattle-container {
        margin-top: 20px;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 5px;
        width: 100%;
        box-sizing: border-box;
        padding-bottom: 20px;
    }
    .cattle-card {
        width: auto !important;
        min-height: auto;
        align-items: center;
        padding: 8px !important;
        aspect-ratio: 1;
        justify-content: center;
    }
    .cattle-card img {
        height: 40px !important;
        width: 40px !important;
        margin-bottom: 2px !important;
    }
    .cattle-card p {
        display: none;
    }
    .cattle-card h3 {
        font-size: 0.7rem;
        margin: 0;
        text-align: center;
    }
    .cattle-container .cattle-card {
        display: flex !important;
    }
    .rule-bubble {
        display: block !important;
        z-index: 1000;
        position: absolute !important;
        top: -110px !important;
    }
    .herd-menu-trigger {
        top: 15px;
        left: auto;
        right: 20px;
        transform: none;
    }
    #herdPhotoMenu {
        left: auto;
        right: 20px;
        top: 50px;
    }
    #profileCircle {
        width: 90px !important;
        height: 90px !important;
        border: none !important;
    }
    #profileCircle img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        transform: scale(1.05);
    }
    #userBalance {
        margin: 10px 0;
        justify-content: center;
        width: 100%;
    }
    #herdLabel {
        display: block !important;
        font-size: 1.2rem;
        font-weight: bold;
    }
}

.rule-bubble {
    display: none;
    position: absolute;
    top: -90px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    width: 180px;
    text-align: center;
    z-index: 25;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.rule-bubble.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.rule-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
}

@media (max-width: 768px) {
    /* Previous mobile styles... */
    .main-card > div[id^="panel"] {
        align-items: center;
        text-align: center;
        background-color: rgba(0, 0, 0, 0.6);
        padding: 1rem;
        border-radius: 15px;
        margin-bottom: 10px;
        margin-top: 80px;
    }
    .main-card > div[id^="panel"] > div {
        justify-content: center;
    }
    .main-card > div > button {
        align-self: center;
    }
}

@keyframes vibrate {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}
.vibrate {
    animation: vibrate 0.3s linear infinite;
}
#rejectionMessage {
    display: none;
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(231, 76, 60, 0.9);
    color: white;
    padding: 5px;
    border-radius: 5px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 30;
}