:root {
    --bs-primary: #4DB6AC;
    --bs-primary-rgb: 77, 182, 172;
    --bs-link-color: #4DB6AC;
    --bs-link-hover-color: #3E948A;
    --bs-pink: #D8AAB7;

    /* Background Gradient Variables */
    --bg-stop-1: #e0f2f1;
    --bg-stop-2: #f3e5f5;
    --bg-stop-3: #e8eaf6;
    --bg-stop-4: #e0f7fa;
    --body-text: #333;
}

@keyframes gradient-animation {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

html {
    min-height: 100%;
    background: linear-gradient(-45deg, var(--bg-stop-1), var(--bg-stop-2), var(--bg-stop-3), var(--bg-stop-4));
    background-size: 400% 400%;
    animation: gradient-animation 20s ease infinite;
    background-attachment: fixed;
}

body {
    min-height: 100%;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    padding-top: 2rem;
    padding-bottom: 2rem;
    color: var(--body-text);
    transition: color 0.3s ease;
}

.container {
    max-width: 720px;
}

.card {
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Subtle border for contrast */
    border-radius: 24px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.12);
    /* Increased shadow depth */
    background: rgba(255, 255, 255, 0.98);
    /* Less transparent for punchier contrast */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-bottom: 2rem;
    transition: transform 0.3s ease;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1.5rem 2rem;
    border-radius: 24px 24px 0 0 !important;
}

.card-body {
    padding: 2rem;
}

h1.h3 {
    font-weight: 800;
    color: #2c3e50;
    letter-spacing: -0.5px;
}

.form-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: #546e7a;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control,
.form-select {
    border-radius: 12px;
    border: 2px solid #eceff1;
    padding: 0.8rem 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background-color: #fcfcfc;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 4px rgba(77, 182, 172, 0.15);
    background-color: #fff;
}

/* Buttons */
.btn {
    border-radius: 12px;
    font-weight: 700;
    padding: 0.6rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #4DB6AC 0%, #26A69A 100%) !important;
    box-shadow: 0 8px 20px rgba(77, 182, 172, 0.25);
    color: white !important;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(77, 182, 172, 0.35);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: #eceff1 !important;
    color: #546e7a !important;
    box-shadow: none !important;
}

.btn-secondary:hover {
    background: #cfd8dc !important;
    color: #37474f !important;
    transform: translateY(-2px);
}

/* Custom Pink Button */
.btn-outline-custom-pink {
    --bs-btn-color: #888;
    --bs-btn-border-color: #D8AAB7;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #D8AAB7;
    --bs-btn-hover-border-color: #D8AAB7;
    --bs-btn-focus-shadow-rgb: 216, 170, 183;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #D8AAB7;
    --bs-btn-active-border-color: #D8AAB7;
    border-width: 2px;
}

.btn-check:checked+.btn-outline-custom-pink {
    background-color: #D8AAB7;
    border-color: #D8AAB7;
    color: white;
    box-shadow: 0 4px 15px rgba(216, 170, 183, 0.4);
}

/* Add Mode Toggle */
#add-mode-toggle {
    background: #f0f2f5;
    border-radius: 50px;
    padding: 4px;
    border: 1px solid #e0e0e0;
}

#add-mode-toggle .btn {
    border-radius: 50px;
    padding: 0.3rem 1rem;
    font-size: 0.8rem;
    color: #777;
    background: transparent !important;
    box-shadow: none !important;
}

#add-mode-toggle .btn-check:checked+.btn {
    background-color: white !important;
    color: var(--bs-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Component List */
.component-list-container {
    border: 3px dashed #e0e0e0;
    border-radius: 20px;
    padding: 1.5rem;
    background-color: #fafafa;
    min-height: 160px;
    transition: all 0.3s ease;
    position: relative;
}

.component-list-container:hover {
    border-color: #b2dfdb;
    background-color: #f0fcfc;
}

#component-list:empty::before {
    content: "Your added components will appear here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #90a4ae;
    font-weight: 500;
    font-style: normal;
    width: 90%;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

.list-group-item {
    border: none;
    border-radius: 16px !important;
    margin-bottom: 0.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 1rem 1.2rem;
    transition: all 0.2s ease;
}

.list-group-item:hover {
    transform: scale(1.01);
}

.list-group-item.removing {
    background-color: #ffebee;
    opacity: 0;
    transform: scale(0.9);
}

.component-name {
    font-size: 1rem;
    font-weight: 700;
    color: #37474f;
}

/* Modals */
.modal-content {
    border-radius: 24px;
    border: none;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #eee;
    padding: 1.5rem;
}

/* Custom Toggle Switch Styles */
.form-switch .form-check-input {
    width: 3.5em;
    height: 1.75em;
    cursor: pointer;
    background-color: #ccc;
    border-color: #ccc;
    transition: background-position .2s ease-in-out;
}

.form-switch .form-check-input:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ccc'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
    background-position: right center;
}

.form-switch .form-check-label {
    font-weight: bold;
    color: #6c757d;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1060;
    display: none;
    justify-content: center;
    align-items: center;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* SEO Content */
.seo-content {
    background-color: rgba(255, 255, 255, 0.5);
    padding: 2.5rem;
    margin-top: 2rem;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Logo Styles */
.logo-img {
    max-width: 150px;
    height: auto !important;
    margin: 0;
    transition: all 0.3s ease;
}

/* ======================= */
/* DARK MODE               */
/* ======================= */

[data-theme="dark"] {
    --bs-body-bg: #121212;
    --bs-body-color: #e0e0e0;
    --bs-primary: #64ffda;
    --bs-primary-rgb: 100, 255, 218;
    --bs-link-color: #64ffda;

    /* Dark Mode Background Gradient */
    --bg-stop-1: #0f172a;
    --bg-stop-2: #1e293b;
    --bg-stop-3: #0f172a;
    --bg-stop-4: #000000;
    --body-text: #e0e0e0;
}


[data-theme="dark"] .card {
    background: rgba(30, 30, 30, 0.95);
    /* Deeper background for punchier contrast */
    border: 1px solid rgba(100, 255, 218, 0.15);
    /* Subtly tinted border using primary color */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    /* Deeper shadow for dark mode lift */
}

[data-theme="dark"] .card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    /* Brighter divider for dark mode */
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
    color: #fff;
}

[data-theme="dark"] .form-label {
    color: #b0bec5;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #263238;
    border-color: #37474f;
    color: #eceff1;
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--bs-primary);
    background-color: #263238;
}

[data-theme="dark"] .form-control::placeholder {
    color: #90a4ae;
    opacity: 1;
}

[data-theme="dark"] .component-list-container {
    background-color: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .list-group-item {
    background-color: #263238;
    color: #fff;
}

[data-theme="dark"] #add-mode-toggle {
    background-color: #263238;
    border-color: #37474f;
}

[data-theme="dark"] #add-mode-toggle .btn {
    color: #90a4ae;
}

[data-theme="dark"] #add-mode-toggle .btn-check:checked+.btn {
    background-color: #37474f !important;
    color: var(--bs-primary) !important;
}

[data-theme="dark"] .modal-content {
    background-color: #263238;
    color: #fff;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background-color: #1e293b;
    border-color: #37474f;
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

[data-theme="dark"] .component-name {
    color: #fff;
}

[data-theme="dark"] .loading-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .seo-content {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .logo-img {
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
}

/* Dropdown Menu Dark Mode Fixes */
[data-theme="dark"] .dropdown-menu {
    background-color: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .dropdown-item {
    color: #e0e0e0;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: rgba(100, 255, 218, 0.1);
    /* Subtle primary tint */
    color: var(--bs-primary);
}

/* Popover & Tooltip Dark Mode Fixes */
[data-theme="dark"] .popover {
    --bs-popover-bg: #263238;
    --bs-popover-border-color: rgba(255, 255, 255, 0.2);
    --bs-popover-header-bg: #37474f;
    --bs-popover-header-color: #ffffff;
    --bs-popover-body-color: #e0e0e0;
    --bs-popover-arrow-border: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .popover-header {
    background-color: #37474f;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .popover-body {
    color: #e0e0e0;
}

[data-theme="dark"] .tooltip {
    --bs-tooltip-bg: #000;
    --bs-tooltip-color: #fff;
}

/* ======================= */
/* MOBILE RESPONSIVENESS   */
/* ======================= */

@media (max-width: 576px) {
    .card-header {
        padding: 1rem 1.2rem;
    }

    .logo-img {
        max-width: 110px;
    }

    .btn-group-sm>.btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Adjust theme toggle margin on mobile */
    .card-header .d-flex .me-3 {
        margin-right: 0.5rem !important;
    }

    /* Fix Add Mode Toggle on Mobile */
    #add-mode-toggle .btn {
        padding: 0.2rem 0.6rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Fix Large Buttons (Reset/Generate) on Mobile */
    .btn-lg {
        padding: 0.5rem 0.8rem;
        font-size: 0.95rem;
        white-space: nowrap;
    }

    /* Support wrapping for language buttons on mobile */
    .language-selector-group {
        display: flex !important;
        flex-wrap: wrap;
        gap: 6px;
    }

    .language-selector-group .btn {
        flex: 1 1 auto;
        border-radius: 12px !important;
        border-width: 2px !important;
    }
}

/* Language Suggestion Banner */
.language-suggestion-banner {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    color: #1e293b;
}

[data-theme="dark"] .language-suggestion-banner {
    background: rgba(30, 41, 59, 0.9) !important;
    color: #f1f5f9;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}