/* Basic reset and global styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f5f7fa; /* Light mode default, will be overridden */
    color: #333;
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode styles (now default) */
body.dark-mode {
    background-color: #2c3e50; /* Darker background */
    color: #ecf0f1; /* Lighter text */
}

body.dark-mode .glassmorphism {
    background: rgba(44, 62, 80, 0.7); /* Darker glass effect */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .problem-type-badge {
    color: #2c3e50; /* Ensure badge text is readable */
}

body.dark-mode .input-with-icon input,
body.dark-mode select,
body.dark-mode .input-with-button input { /* Added input-with-button input */
    background-color: #34495e; /* Darker input fields */
    border-color: #4a6480;
    color: #ecf0f1;
}

body.dark-mode .input-icon,
body.dark-mode .select-arrow,
body.dark-mode label,
body.dark-mode .subtitle,
body.dark-mode .problem-contest-id,
body.dark-mode .meta-item,
body.dark-mode .problem-tags span,
body.dark-mode footer,
body.dark-mode .stat-label,
body.dark-mode .filter-logic-display,
body.dark-mode .status-message { /* Added status-message */
    color: #bdc3c7;
}

body.dark-mode .next-btn {
    background: #34495e;
    border-color: #4a6480;
    color: #ecf0f1;
}

body.dark-mode .difficulty-bar-container {
    background: #4a6480;
}

body.dark-mode .loading p {
    color: #ecf0f1;
}


/* Tag-specific dark mode styles */
body.dark-mode .tag-buttons-container {
    background: rgba(44, 62, 80, 0.7); /* Darker glass effect for tags */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .tag-button {
    background-color: #34495e; /* Dark background for unselected tags */
    border: 1px solid #4a6480;
    color: #ecf0f1;
}

body.dark-mode .tag-button:hover:not(.selected) {
    background-color: #4a6480; /* Darker hover for unselected */
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    position: relative;
}

.logo-symm {
    color: #4a6bff;
}

.logo-div2 {
    color: #ff6b6b;
}

.logo-badge {
    font-size: 0.8rem;
    background: #ff6b6b;
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 10px;
    position: absolute;
    top: -10px;
    right: -30px;
    animation: bounceIn 1s ease-out;
}

h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #333; /* Default light mode */
    transition: color 0.3s ease;
}

body.dark-mode h1 {
    color: #ecf0f1; /* Override for dark mode */
}

.subtitle {
    color: #666; /* Default light mode */
    font-size: 1.1rem;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.header-decoration {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.decoration-circle {
    width: 10px;
    height: 10px;
    background-color: #4a6bff;
    border-radius: 50%;
    animation: pulse-small 2s infinite ease-in-out;
}

.decoration-circle:nth-child(2) {
    animation-delay: 0.2s;
    background-color: #ff6b6b;
}

.decoration-circle:nth-child(3) {
    animation-delay: 0.4s;
    background-color: #00cec9;
}

@keyframes pulse-small {
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.6; }
}


/* Controls section */
.controls {
    margin-bottom: 30px;
}

.glassmorphism {
    background: rgba(255, 255, 255, 0.8); /* Default light mode */
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.filter-item {
    margin-bottom: 15px;
}

.filter-row {
    display: flex;
    gap: 15px;
}

.filter-row .filter-item {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555; /* Default light mode */
    transition: color 0.3s ease;
}

.select-wrapper {
    position: relative;
}

select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: white; /* Default light mode */
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #4a6bff;
    box-shadow: 0 0 0 3px rgba(74, 107, 255, 0.2);
}

.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #777; /* Default light mode */
    transition: color 0.3s ease;
}

.input-with-icon {
    position: relative;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 15px 12px 35px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-with-icon input:focus,
.input-with-button input:focus { /* Added input-with-button input focus */
    outline: none;
    border-color: #4a6bff;
    box-shadow: 0 0 0 3px rgba(74, 107, 255, 0.2);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #777; /* Default light mode */
    transition: color 0.3s ease;
}

/* Reduced opacity for rating stars */
.input-icon.rating-star {
    opacity: 0.6;
}

/* Hide default up/down buttons for number input */
/* For Chrome, Safari, Edge, Opera */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* For Firefox */
input[type="number"] {
    -moz-appearance: textfield;
}

/* Codeforces Handle input with button */
.input-with-button {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-button input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: white; /* Default light mode */
}

.small-button {
    padding: 10px 18px; /* Smaller padding for this button */
    font-size: 0.9rem;
    white-space: nowrap; /* Prevent text wrapping */
}

.status-message {
    display: block;
    margin-top: 5px;
    font-size: 0.85em;
    color: #888; /* Default color */
    height: 1.2em; /* Reserve space to prevent layout shift */
    line-height: 1.2em;
}

.status-message.success {
    color: #27ae60; /* Green */
}

.status-message.error {
    color: #e74c3c; /* Red */
}

/* Tag Buttons Container */
.tags-filter-item {
    margin-top: 20px;
}

.filter-logic-display {
    color: #666; /* Adjust for dark mode if needed */
    font-size: 0.9em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.filter-logic-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #00cec9; /* Example dot color */
    border-radius: 50%;
    margin-right: 8px;
}


.tag-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 15px; /* Added padding for glassmorphism effect */
    border-radius: 15px; /* Matching filter-group border-radius */
    background: rgba(255, 255, 255, 0.8); /* Default light glassmorphism */
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.tag-button {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 20px;
    background-color: #e0e0e0; /* Default unselected light mode */
    color: #333; /* Default unselected text color */
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid #ccc;
    user-select: none; /* Prevent text selection on click */
}

.tag-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background-color: #d0d0d0; /* Slight hover effect */
}

/* Selected tag style - Red-Orange gradient */
.tag-button.selected {
    background: linear-gradient(90deg, #ff6b6b, #e17055);
    color: white;
    border-color: #ff6b6b;
    transform: translateY(-2px); /* Lift slightly on selection */
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4);
}

.tag-button.selected:hover {
    transform: translateY(-3px); /* More lift on hover when selected */
    box-shadow: 0 6px 15px rgba(255, 107, 107, 0.6);
}


/* Buttons */
button, .btn {
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none; /* For anchor buttons */
}

#generate-btn {
    background: linear-gradient(135deg, #4a6bff, #6b4aff);
    color: white;
    width: 100%;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(74, 107, 255, 0.4);
}

.glow-on-hover:hover {
    box-shadow: 0 0 20px rgba(74, 107, 255, 0.7);
    transform: translateY(-2px);
}

.btn-icon {
    margin-right: 8px;
}

.btn-hover-effect {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

button:hover .btn-hover-effect,
.btn:hover .btn-hover-effect {
    left: 100%;
}

/* Problem card */
.problem-card {
    background: rgba(255, 255, 255, 0.8); /* Default light mode */
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.problem-header {
    margin-bottom: 20px;
    position: relative;
}

.problem-type-badge {
    display: inline-block;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    text-align: center;
    line-height: 35px;
    font-weight: 700;
    color: white; /* Default light mode */
    margin-right: 10px;
    font-size: 1rem;
    vertical-align: middle;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.problem-type-A { background-color: #00b894; } /* Green */
.problem-type-B { background-color: #00cec9; } /* Cyan */
.problem-type-C { background-color: #0984e3; } /* Blue */
.problem-type-D { background-color: #6c5ce7; } /* Purple */
.problem-type-E { background-color: #fd79a8; } /* Pink */
.problem-type-F { background-color: #e17055; } /* Orange */
.problem-type-G { background-color: #d63031; } /* Red */

#problem-title {
    display: inline;
    font-size: 1.5rem;
    font-weight: 600;
    vertical-align: middle;
    transition: color 0.3s ease;
}

.problem-contest-id {
    color: #666; /* Default light mode */
    margin-top: 5px;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

/* Difficulty meter */
.difficulty-meter {
    margin-top: 20px;
    position: relative;
}

.difficulty-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.8rem;
    color: #666; /* Default light mode */
    transition: color 0.3s ease;
}

.difficulty-bar-container {
    height: 8px;
    background: #eee; /* Light mode background for the track */
    border-radius: 4px;
    position: relative;
    margin-bottom: 30px;
    overflow: hidden; /* Ensure fill stays within bounds */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease;
}

body.dark-mode .difficulty-bar-container {
    background: #4a6480; /* Dark mode background for the track */
}

.difficulty-bar-track { /* This div now explicitly serves as the full background track */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* No specific background, just the container's */
    border-radius: inherit;
}

.difficulty-bar-fill { /* The actual growing bar */
    height: 100%;
    width: 0%; /* Starts at 0, will be controlled by JS */
    /* Updated gradient for better matching */
    background: linear-gradient(90deg, 
        #00b894 0%, /* Newbie */
        #00b894 14.81%, /* Newbie ends at 1200 */
        #00cec9 14.81%, /* Specialist starts at 1200 */
        #00cec9 22.22%, /* Specialist ends at 1400 */
        #0984e3 22.22%, /* Expert starts at 1400 */
        #0984e3 29.63%, /* Expert ends at 1600 */
        #6c5ce7 29.63%, /* Candidate Master starts at 1600 */
        #6c5ce7 40.74%, /* Candidate Master ends at 1900 */
        #fd79a8 40.74%, /* Master starts at 1900 */
        #fd79a8 48.15%, /* Master ends at 2100 */
        #e17055 48.15%, /* International Master starts at 2100 */
        #e17055 55.56%, /* International Master ends at 2300 */
        #d63031 55.56%, /* Grandmaster+ starts at 2300 */
        #d63031 100% /* Grandmaster+ continues to end */
    );
    border-radius: 4px;
    transition: width 0.5s ease-out; /* Smooth transition for width */
    position: absolute; /* Position it to grow from left */
    top: 0;
    left: 0;
    z-index: 1; /* Ensure it's below the pointer if pointer overlaps */
}

.difficulty-pointer {
    position: absolute;
    top: -15px; /* Position above the bar */
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 15px solid #4a6bff; /* Pointing triangle */
    transform: translateX(-50%); /* Center the pointer */
    transition: left 0.5s ease-out, border-top-color 0.3s ease;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
    z-index: 2; /* Ensure pointer is above the fill */
}

/* Problem meta */
.problem-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #555; /* Default light mode */
    font-weight: 500;
    transition: color 0.3s ease;
}

.meta-item i {
    color: #4a6bff; /* Icon color */
}

/* Solved Status Badge */
.problem-solved-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    display: inline-flex; /* Use inline-flex for better alignment */
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-width: 90px; /* Ensure consistent width */
    justify-content: center;
}

.problem-solved-status.solved {
    background: linear-gradient(90deg, #2ecc71, #27ae60); /* Green gradient */
}

.problem-solved-status.unsolved {
    background: linear-gradient(90deg, #e74c3c, #c0392b); /* Red gradient */
}

/* Tags in problem display */
.problem-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 25px;
}

.problem-tags span {
    background: #e0e0e0; /* Default light mode */
    padding: 6px 12px;
    border-radius: 25px;
    font-size: 0.85rem;
    color: #555; /* Default light mode */
    transition: all 0.3s ease;
    cursor: default;
    border: 1px solid #ccc; /* Default light mode */
}

body.dark-mode .problem-tags span {
    background: #4a6480;
    color: #ecf0f1;
    border-color: #5f7a99;
}

.problem-tags span:hover {
    background: #d0d0d0; /* Default light mode */
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

body.dark-mode .problem-tags span:hover {
    background: #5f7a99;
}

/* Actions */
.actions {
    display: flex;
    gap: 15px;
}

.solve-btn {
    background: linear-gradient(135deg, #4a6bff, #6b4aff);
    color: white;
    flex: 2;
    box-shadow: 0 4px 15px rgba(74, 107, 255, 0.4);
}

.next-btn {
    background: #f5f7fa; /* Default light mode */
    border: 1px solid #ddd; /* Default light mode */
    flex: 1;
    color: #333; /* Default light mode */
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.8); /* Default light mode */
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a6bff, #00cec9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: rotate-in 0.6s ease-out;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333; /* Default light mode */
    transition: color 0.3s ease;
}

body.dark-mode .stat-value {
    color: #ecf0f1; /* Override for dark mode */
}

.stat-label {
    font-size: 0.9rem;
    color: #666; /* Default light mode */
    transition: color 0.3s ease;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
}

.spinner-blade {
    position: absolute;
    left: 44.5%;
    top: 37%;
    width: 10%;
    height: 25%;
    border-radius: 50%/20%;
    background-color: #4a6bff;
    animation: spinner-fade 1s linear infinite;
}

@keyframes spinner-fade {
    0% { opacity: 1; }
    100% { opacity: 0.15; }
}

.spinner-blade:nth-child(1) {
    animation-delay: 0s;
    transform: rotate(0deg) translate(0, -150%);
}

.spinner-blade:nth-child(2) {
    animation-delay: 0.125s;
    transform: rotate(45deg) translate(0, -150%);
}

.spinner-blade:nth-child(3) {
    animation-delay: 0.25s;
    transform: rotate(90deg) translate(0, -150%);
}

.spinner-blade:nth-child(4) {
    animation-delay: 0.375s;
    transform: rotate(135deg) translate(0, -150%);
}

.spinner-blade:nth-child(5) {
    animation-delay: 0.5s;
    transform: rotate(180deg) translate(0, -150%);
}

.spinner-blade:nth-child(6) {
    animation-delay: 0.625s;
    transform: rotate(225deg) translate(0, -150%);
}

.spinner-blade:nth-child(7) {
    animation-delay: 0.75s;
    transform: rotate(270deg) translate(0, -150%);
}

.spinner-blade:nth-child(8) {
    animation-delay: 0.875s;
    transform: rotate(315deg) translate(0, -150%);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    color: #666; /* Default light mode */
    padding-bottom: 20px;
    transition: color 0.3s ease;
}

.heart-pulse {
    color: #ff6b6b;
    display: inline-block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px 0;
}

.social-link {
    color: #4a6bff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.social-link:hover {
    color: #6b4aff;
    transform: translateY(-2px);
}

.credit {
    font-size: 0.9rem;
    margin-top: 10px;
    transition: color 0.3s ease;
}

.footer-decoration {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.decoration-dot {
    width: 8px;
    height: 8px;
    background-color: #00cec9;
    border-radius: 50%;
    animation: fade-in-out 2s infinite ease-in-out;
}

.decoration-dot:nth-child(2) {
    animation-delay: 0.3s;
    background-color: #ff6b6b;
}

.decoration-dot:nth-child(3) {
    animation-delay: 0.6s;
    background-color: #4a6bff;
}

@keyframes fade-in-out {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}


/* Utility classes */
.hidden {
    display: none !important;
}

/* Animations for new content */
.animate__fadeIn {
    animation-duration: 0.8s;
}

.animate__fadeInDown {
    animation-duration: 0.8s;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .logo {
        font-size: 2rem;
    }

    .logo-badge {
        position: static; /* Adjust for smaller screens */
        margin-top: 10px;
    }

    .problem-type-badge {
        width: 30px;
        height: 30px;
        line-height: 30px;
        font-size: 0.8rem;
    }

    #problem-title {
        font-size: 1.3rem;
    }

    .stat-item {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        margin-bottom: 10px;
    }

    .tag-buttons-container {
        padding: 10px; /* Adjust padding for smaller screens */
    }

    .tag-button {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 10px;
    }

    .logo {
        font-size: 1.8rem;
    }

    h1 {
        font-size: 1.3rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .filter-group, .problem-card, .stat-item {
        padding: 15px;
    }

    .input-with-icon input, select, button, .btn, .input-with-button input {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .btn-icon {
        margin-right: 5px;
    }
    
    .input-with-button {
        flex-direction: column;
        gap: 8px;
    }

    .input-with-button input, .input-with-button button {
        width: 100%;
    }
}
