html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.main-wrapper {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.wave-top {
    position: relative;
    height: 180px;
    background-color: #d3f1ff;
    overflow: hidden;
    margin-bottom: -50px;
}

.wave-top svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    fill: rgba(255,255,255,0.6);
}

.wave-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding-top: 50px;
}

.wave-content h2 {
    font-size: 1.8rem;
    color: #003366;
    font-weight: 700;
    margin: 0;
}

.content-container {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
}

.glass-card {
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 15px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.1);
    padding: 25px 30px;
}

#campaignForm .form-control-lg,
#campaignForm .form-select-lg {
    font-size: 1rem;
    padding: 0.6rem 1rem;
}

#fetchBtn {
    background: linear-gradient(135deg,#1EAE98,#2BCDD2);
    border: none;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    padding: 0.6rem 1rem;
    font-size: 1rem;
}

#fetchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(43,205,210,0.4);
}

.status-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin: 5px 0;
    font-weight: 500;
}

/* Ensure these are specific enough if Bootstrap overrides them */
.status-badge.bg-success { background-color: #198754 !important; color: #fff !important; }
.status-badge.bg-warning { background-color: #ffc107 !important; color: #000 !important; }
.status-badge.bg-danger { background-color: #dc3545 !important; color: #fff !important; }
.status-badge.bg-secondary { background-color: #6c757d !important; color: #fff !important; }
.status-badge.bg-info { background-color: #0dcaf0 !important; color: #000 !important; }


#campaignInfo {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

#campaignTitle {
    font-size: 1.3rem;
    margin-bottom: 5px;
    font-weight: 600;
    color: #003366;
}

.stop-time {
    font-size: 0.85rem;
    color: #555;
    font-style: italic;
    margin-top: 5px;
}

.section-title {
    margin: 30px 0 20px 0;
    text-align: center;
    font-weight: 600;
    color: #004A7F;
    font-size: 1.4rem;
}

.metric-box {
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    color: #fff; /* Default color, specific backgrounds will override */
    background-color: #777; /* Default background */
}

.metric-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}

.metric-box div:first-child {
    opacity: 0.9;
    font-size: 0.8em;
    margin-bottom: 3px;
}

.metric-box div:last-child {
    font-size: 1.2em;
    font-weight: 700;
}

.bg-impressions { background-image: linear-gradient(to right, #ffecd2 0%, #fcb69f 100%); color: #795548;}
.bg-clicks { background-image: linear-gradient(to right, #fff2c1 0%, #ffe179 100%); color: #7b662b;}
.bg-spend { background-image: linear-gradient(to right, #ffcdd2 0%, #ffa1a8 100%); color: #9c161c;}
.bg-messages { background-image: linear-gradient(to right, #d4fc79 0%, #96e6a1 100%); color: #1e5526;}
.bg-likes { background-image: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%); color: #0d47a1;}
.bg-purchases { background-image: linear-gradient(to right, #e0c3fc 0%, #8ec5fc 100%); color: #3f007d;}
.bg-daily { background-image: linear-gradient(to right, #fbc2eb 0%, #a6c1ee 100%); color: #8c115d;}
.bg-lifetime { background-image: linear-gradient(to right, #fddb92 0%, #d1fdff 100%); color: #7c5a00;}
.bg-views { background-image: linear-gradient(to right, #84fab0 0%, #8fd3f4 100%); color: #004d40;}
.bg-thruplay { background-image: linear-gradient(to right, #ff9a9e 0%, #fecfef 100%); color: #ad1457;}
.bg-adcost { background-image: linear-gradient(to right, #fff3b0 0%, #ffd166 100%); color: #b26a00; }
.bg-objective { background-color: rgba(43,205,210,0.08); color: #1EAE98; border: 1px solid rgba(43,205,210,0.2); }
.bg-calc-metric { background-color: rgba(128,128,128,0.05); color: #555; border: 1px solid rgba(128,128,128,0.15); }


.ad-card {
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.ad-image {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.ad-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #005A9C;
    margin-bottom: 5px;
    line-height: 1.3;
    min-height: 40px;
}


.ad-card .metric-box {
    font-size: 0.8rem;
    padding: 8px 5px;
    margin-bottom: 8px;
}

.ad-card .metric-box div:last-child {
    font-size: 1em;
}

footer {
    flex-shrink: 0;
    background: #003366;
    color: #fff;
    text-align: center;
    padding: 1rem;
    margin-top: 30px;
}

footer p {
    margin: 0;
    font-weight: 500;
    font-size: 0.9rem;
}
.footer-heart {
    color: #ff6b6b;
}

#spinnerOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.ringSpinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ccc;
    border-top: 5px solid #1EAE98;
    border-radius: 50%;
    animation: ringSpin 0.8s linear infinite;
}

@keyframes ringSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.skeleton {
    animation: skeleton-loading 1.2s linear infinite alternate;
    background: #e9ecef;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-color: #f8f9fa; }
    100% { background-color: #e9ecef; }
}

#errorMessage,
#warningMessage,
#resultsHr,
#resultsContainer,
#skeletonContainer {
    display: none;
}

.alert {
    border-radius: 8px;
    font-size: 0.9rem;
}

.chart-container {
    position: relative;
    margin: auto;
    height: 360px;
    width: 100%;
    max-width: 580px;
    margin-bottom: 30px;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}
#majorCitiesRowEl .chart-container {
    max-width: 100%;
    height: 400px;
}

.top-performer-box {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.07);
    transition: all 0.3s ease;
}
.top-performer-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.top-performer-box h5 {
    font-size: 0.9rem;
    color: #1EAE98;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.top-performer-box p {
    font-size: 1.15rem;
    font-weight: 700;
    color: #343a40;
    margin-bottom: 4px;
}
.top-performer-box .metric-label {
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
    margin-top: 2px;
}

#datePresetSelect {
    font-weight: 500;
    border-color: #1EAE98;
}
#datePresetSelect:focus {
    box-shadow: 0 0 0 0.25rem rgba(30, 174, 152, 0.3);
    border-color: #1EAE98;
}

@media (max-width: 768px) {
    .ad-image { max-height: 180px; }
    .chart-container { height: 300px; }
    #majorCitiesRowEl .chart-container { height: 330px; }
    .wave-top { height: 160px; margin-bottom: -40px; }
    .wave-content h2 { font-size: 1.6rem; }
}

@media (max-width: 576px) {
    .wave-top { height: 140px; margin-bottom: -30px; }
    .wave-content { padding-top: 40px; }
    .wave-content h2 { font-size: 1.3rem; }
    .glass-card { padding: 20px 15px; }
    .ad-image { max-height: 150px; }
    .chart-container { height: 260px; padding: 10px; }
    #majorCitiesRowEl .chart-container { height: 280px; }
    .top-performer-box { padding: 15px; }
    .top-performer-box h5 { font-size: 0.85rem; }
    .top-performer-box p { font-size: 1.05rem; }
}