/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light Mode Variables */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: linear-gradient(145deg, #ffffff, #f7fafc);
    --text-primary: #333;
    --text-secondary: #4a5568;
    --text-heading: #2d3748;
    --header-bg: rgba(255, 255, 255, 0.95);
    --search-bg: rgba(255, 255, 255, 0.9);
    --search-focus-bg: white;
    --modal-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    --border-color: rgba(255, 255, 255, 0.3);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --scrollbar-track: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --bg-gradient: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --card-bg: linear-gradient(145deg, #2d3748, #4a5568);
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e0;
    --text-heading: #f7fafc;
    --header-bg: rgba(45, 55, 72, 0.95);
    --search-bg: rgba(74, 85, 104, 0.9);
    --search-focus-bg: #4a5568;
    --modal-bg: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --scrollbar-track: rgba(255, 255, 255, 0.05);
}

body {
    font-family: "Poppins", sans-serif;
    background: var(--bg-gradient);
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Theme Toggle Switch */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-switch {
    display: inline-block;
    width: 60px;
    height: 34px;
    position: relative;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "🌙";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    font-size: 14px;
}

input:checked+.slider {
    background: linear-gradient(135deg, #f6e05e, #ed8936);
}

input:checked+.slider:before {
    transform: translateX(26px);
    content: "☀️";
}

/* Header Styles */
header {
    text-align: center;
    padding: 30px 20px;
    background: var(--header-bg);
    box-shadow: 0 8px 32px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

h1 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 4px var(--shadow-color);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

#search {
    padding: 15px 25px;
    width: 70%;
    max-width: 500px;
    border-radius: 50px;
    border: none;
    outline: none;
    font-size: 16px;
    background: var(--search-bg);
    color: var(--text-primary);
    box-shadow:
        inset 0 2px 4px var(--shadow-color),
        0 4px 15px var(--shadow-color);
    transition: all 0.3s ease;
    margin-top: 10px;
}

#search:focus {
    background: var(--search-focus-bg);
    box-shadow:
        inset 0 2px 4px var(--shadow-color),
        0 6px 20px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

#search::placeholder {
    color: #a0aec0;
}

/* Main Content */
.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.country-card {
    background: var(--card-bg);
    border-radius: 20px;
    text-align: center;
    padding: 25px 20px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow:
        0 10px 25px var(--shadow-color),
        0 5px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.country-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.country-card:hover::before {
    left: 100%;
}

.country-card:hover {
    transform: translateY(-12px) scale(1.03);
    box-shadow:
        0 20px 40px var(--shadow-color),
        0 15px 25px rgba(0, 0, 0, 0.1);
}

.country-card img {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 3px solid var(--header-bg);
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: all 0.3s ease;
}

.country-card:hover img {
    transform: scale(1.1) rotate(2deg);
    border-color: #667eea;
}

.country-card h3 {
    margin-top: 15px;
    color: var(--text-heading);
    font-weight: 600;
    font-size: 1.2rem;
    position: relative;
    padding-bottom: 8px;
}

.country-card h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.country-card:hover h3::after {
    width: 60px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--modal-bg);
    margin: 5% auto;
    padding: 40px;
    border-radius: 25px;
    width: 85%;
    max-width: 500px;
    text-align: center;
    box-shadow:
        0 25px 50px var(--shadow-color),
        0 15px 30px rgba(0, 0, 0, 0.22);
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 25px 25px 0 0;
}

.modal-content img {
    width: 200px;
    height: 140px;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 8px 25px var(--shadow-color);
    border: 4px solid var(--header-bg);
    margin-bottom: 20px;
}

.close {
    color: #a0aec0;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
    transform: rotate(90deg);
}

/* Detail items styling */
#modal-name {
    color: var(--text-heading);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 25px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#modal-continent,
#modal-capital,
#modal-currency,
#modal-language,
#modal-area {
    padding: 12px 0;
    border-bottom: 1px solid;
    border-color: var(--border-color);
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-align: left;
    margin: 0 20px;
}

#modal-continent:last-child {
    border-bottom: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .country-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 20px;
        padding: 30px 15px;
    }

    #search {
        width: 85%;
        padding: 12px 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .modal-content {
        margin: 10% auto;
        padding: 30px 25px;
        width: 90%;
    }

    .modal-content img {
        width: 160px;
        height: 110px;
    }

    .theme-toggle {
        top: 15px;
        right: 15px;
    }

    .theme-switch {
        width: 50px;
        height: 28px;
    }

    .slider:before {
        height: 20px;
        width: 20px;
        font-size: 12px;
    }

    input:checked+.slider:before {
        transform: translateX(22px);
    }
}

@media (max-width: 480px) {
    .country-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .country-card {
        padding: 20px 15px;
    }

    .country-card img {
        width: 100px;
        height: 70px;
    }

    #search {
        width: 90%;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* Loading animation for cards */
.country-card {
    animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* Footer Styles */
.footer {
    background: var(--header-bg);
    color: var(--text-primary);
    padding: 40px 20px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -5px 20px var(--shadow-color);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 20px;
}

.footer-section h3 {
    color: var(--text-heading);
    margin-bottom: 15px;
    font-size: 1.4rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.footer-section h4 {
    color: var(--text-heading);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
    position: relative;
    padding-left: 15px;
}

.footer-section ul li a::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #667eea;
    transition: transform 0.3s ease;
}

.footer-section ul li a:hover {
    color: #667eea;
}

.footer-section ul li a:hover::before {
    transform: translateX(3px);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 20px;
        text-align: center;
    }

    .footer-section ul li a {
        padding-left: 0;
    }

    .footer-section ul li a::before {
        display: none;
    }

    .contact-icon {
        width: 50px;
        height: 50px;
        background: var(--gradient-primary);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        color: white;
    }

    /* ===== ROOT THEME COLORS ===== */
    :root {
        --bg-color: #ffffff;
        --text-color: #222;
        --text-secondary: #555;
        --footer-bg: #f4f4f4;
        --footer-text: #333;
    }

    [data-theme="dark"] {
        --bg-color: #1c1c1c;
        --text-color: #f1f1f1;
        --text-secondary: #bbb;
        --footer-bg: #222;
        --footer-text: #ddd;
    }

    /* ===== BASE STYLE ===== */
    body {
        margin: 0;
        font-family: Arial, sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        transition: background 0.3s, color 0.3s;
    }

    header {
        text-align: center;
        padding: 30px 15px;
    }

    .header-content h1 {
        font-size: 2rem;
    }

    .subtitle {
        color: var(--text-secondary);
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .search-container {
        display: flex;
        justify-content: center;
        width: 100%;
        max-width: 500px;
        margin: auto;
    }

    #search {
        width: 100%;
        padding: 10px;
        border-radius: 10px;
        border: 1px solid #ccc;
        outline: none;
    }

    /* ===== FOOTER ===== */
    .footer {
        background-color: var(--footer-bg);
        color: var(--footer-text);
        padding: 30px 15px;
        text-align: center;
    }

    .footer-content {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2rem;
        max-width: 1000px;
        margin: auto;
    }

    .footer-section {
        flex: 1;
        min-width: 250px;
        text-align: left;
    }

    .footer-section ul {
        list-style: none;
        padding: 0;
    }

    .footer-section a {
        text-decoration: none;
        color: inherit;
        transition: 0.3s;
    }

    .footer-section a:hover {
        color: #1da1f2;
    }

    .footer-bottom {
        margin-top: 20px;
        border-top: 1px solid #444;
        padding-top: 10px;
        font-size: 0.9rem;
    }

    /* ===== RESPONSIVE DESIGN ===== */
    @media (max-width: 768px) {
        .footer-content {
            flex-direction: column;
            align-items: center;
        }

        .header-content h1 {
            font-size: 1.6rem;
        }
    }

    /* ===== THEME TOGGLE ===== */
    .theme-toggle {
        position: fixed;
        top: 15px;
        right: 15px;
    }

    .theme-switch {
        position: relative;
        display: inline-block;
        width: 50px;
        height: 25px;
    }

    .theme-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .slider {
        position: absolute;
        cursor: pointer;
        background-color: #ccc;
        border-radius: 34px;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transition: 0.4s;
    }

    .slider:before {
        position: absolute;
        content: "";
        height: 19px;
        width: 19px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        border-radius: 50%;
        transition: 0.4s;
    }

    input:checked+.slider {
        background-color: #2196f3;
    }

    input:checked+.slider:before {
        transform: translateX(24px);
    }

}