:root {
    --white: #ffffff;
    --light-blue: #e3f2fd;
    --blue: #1e88e5;
    --dark-blue: #0d47a1;
    --light-gray: #f5f5f5;
    --gray: #e0e0e0;
    --dark-gray: #383838;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: var(--light-gray);
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    position: relative;
    min-height: 100vh; /* Ensure full viewport height */
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

.container {
    max-width: 800px;
    width: 70%;
    margin: 20px auto;
    background-color: rgba(255, 255, 255, 0.6); /* Semi-transparent white background */
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    z-index: 5; /* Ensure container is above background images */
    backdrop-filter: blur(5px); /* Slight blur effect for better readability */
    -webkit-backdrop-filter: blur(5px); /* For Safari support */
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--blue), var(--dark-blue));
}

h1 {
    color: var(--dark-blue);
    margin-bottom: 5px;
    font-weight: 700;
    font-size: 2rem;
    text-align: center;
    position: relative;
    padding-bottom: 10px;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--dark-blue));
}

h2 {
    color: var(--dark-blue);
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 1.5rem;
}

h3 {
    color: var(--dark-blue);
    margin: 5px 0 0px;
    font-weight: 500;
    font-size: 1.2rem;
}

h4 {
    margin-top: 5px;
    padding-top: 5px;
}

p {
    margin-bottom: 5px;
    color: var(--dark-gray);
    font-weight: bold;
}

code {
    background-color: var(--light-blue);
    padding: 1px 1px;
    border-radius: 3px;
    font-family: monospace;
    color: var(--dark-blue);
}

textarea {
    width: 100%;
    min-height: 200px;
    margin-bottom: 5px;
    padding: 10px;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    font-family: monospace;
    resize: vertical;
    transition: border-color 0.3s;
    background-color: var(--white); /* Ensure textarea has opaque background */
}

textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

textarea.error {
    border-color: #f44336;
    background-color: #ffebee;
    box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.2);
}

input {
    padding: 8px 10px;
    margin-bottom: 5px;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    transition: border-color 0.3s;
    background-color: var(--white); /* Ensure input has opaque background */
}


input[type="text"] {
    width: 100%;
}


input[type="text"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

button {
    background-color: var(--blue);
    color: var(--white);
    padding: 8px 15px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s, transform 0.2s;
    opacity: 1; /* Ensure full opacity */
}

button:hover {
    background-color: var(--dark-blue);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.result {
    margin-top: 3px;
    padding: 5px;
    background-color: var(--light-blue);
    border-radius: var(--border-radius);
    border-left: 5px solid var(--blue);
    white-space: normal;
    font-family: monospace;
    display: none;
    font-size: 14px;
    opacity: 1; /* Ensure full opacity */
}

.error {
    background-color: #ffebee;
    border-left: 5px solid #f44336;
}

.expression-container {
    background-color: rgba(219, 248, 250, 0.5); /* Semi-transparent white background */
    padding: 5px;
    margin-bottom: 5px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    border-left: 5px solid transparent;
    opacity: 1; /* Ensure full opacity */
}

.expression-container.error {
    background-color: #ffebee;
    border-left: 5px solid #f44336;
}

.condition-error-message {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
    padding: 5px;
    background-color: rgba(244, 67, 54, 0.1);
    border-radius: 4px;
    display: none;
}

/* Caret position is now shown in real-time */

.expression-input-container {
    position: relative;
    margin-bottom: 5px;
}

.expression-input {
    width: 100%;
}

.caret-position-display {
    position: absolute;
    bottom: -18px;
    right: 0;
    font-size: 12px;
    color: #757575;
    font-family: monospace;
    background-color: transparent;
    padding: 2px 5px;
    border-radius: 3px;
}

.expression-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expression-title {
    font-weight: 500;
    color: var(--dark-blue);
}

.add-expression {
    margin-bottom: 5px;
    background-color: var(--dark-blue);
}

.remove-btn {
    background-color: transparent;
    color: #f44336;
    padding: 3px 8px;
    font-size: 12px;
    top: 8px;
    right: 8px;
}

.remove-btn:hover {
    background-color: rgba(244, 67, 54, 0.1);
    transform: none;
}


/* Tab styles */
.tabs {
    margin-bottom: 15px;
}

.tab-headers {
    display: flex;
    border-bottom: 2px solid var(--gray);
    margin-bottom: 10px;
}

.tab-header {
    padding: 8px 15px;
    cursor: pointer;
    margin-right: 5px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    font-weight: 500;
    background-color: var(--light-gray);
    transition: all 0.3s;
    opacity: 1; /* Ensure full opacity */
}

.tab-header.active {
    background-color: var(--light-blue);
    border-color: var(--gray);
    border-bottom: 2px solid var(--light-blue);
    margin-bottom: -2px;
    color: var(--dark-blue);
    opacity: 1; /* Ensure full opacity */
}

.tab-header:hover:not(.active) {
    background-color: var(--gray);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

#xml-editor {
    width: 100%;
    min-height: 350px;
    margin-bottom: 15px;
    font-family: monospace;
    padding: 10px;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    resize: vertical;
    white-space: nowrap;
    overflow: auto;
}

#xml-editor.error {
    border-color: #f44336;
    background-color: #ffebee;
}

.btn-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.btn-container button {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
}

/* Statistics container */
.stats-container {
    margin-top: 5px;
    padding-left: 15px;
    background-color: #e8f5e9;
    border-radius: var(--border-radius);
    border-left: 5px solid #4caf50;
    white-space: normal;
    font-family: monospace;
    font-size: 14px;
    opacity: 1; /* Ensure full opacity */
}

.stats-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2e7d32;
}

#stats-content {
    line-height: 1.6;
    padding: 10px 0;
}

#stats-content p {
    margin: 8px 0;
    padding: 1px 0;
}

#stats-content .error-message {
    color: #f44336;
    font-weight: 500;
}

.hidden {
    display: none;
}

/* Examples and More Info Styles */
.examples-link, .more-info-link {
    color: var(--blue);
    text-decoration: underline;
    cursor: pointer;
}

.examples-link:hover, .more-info-link:hover {
    color: var(--dark-blue);
}

.examples-container, .more-info-container {
    margin: 8px 8px;
    padding: 10px;
    background-color: var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.7;
    border-left: 3px solid var(--blue);
    opacity: 1; /* Ensure full opacity */
}

/* FAQ Styles */
.faq-container {
    margin-bottom: 15px;
    padding: 3px;
    background-color: var(--light-blue);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    opacity: 1; /* Ensure full opacity */
}

.faq-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    cursor: pointer;
    padding: 5px;
}

.faq-title h3 {
    margin: 0;
}

.faq-buttons {
    display: flex;
    align-items: center;
}

.faq-list {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    background-color: var(--white);
    padding: 10px;
    opacity: 1; /* Ensure full opacity */
}

.faq-item {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--gray);
    padding-bottom: 15px;
}

.faq-item:last-child {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.faq-question {
    font-weight: 600;
    color: var(--dark-blue);
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.faq-answer {
    color: var(--dark-gray);
    line-height: 1.5;
}

/* Deck History Styles */
.history-container {
    margin-bottom: 5px;
    padding: 3px;
    background-color: var(--light-blue);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    opacity: 1; /* Ensure full opacity */
}

.history-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    cursor: pointer;
    padding: 5px;
}

.history-title h3 {
    margin: 0;
}

.history-buttons {
    display: flex;
    align-items: center;
    visibility: visible; /* Changed from hidden to visible to show the collapse indicator button */
}

.history-list {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    background-color: var(--white);
    opacity: 1; /* Ensure full opacity */
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    padding: 8px;
    border-bottom: 1px solid var(--gray);
    background-color: var(--light-gray);
}

#clear-history-btn.remove-btn {
    color: #f44336;
    border: 1px solid #f44336;
    background-color: transparent;
    border-radius: 4px;
    font-size: 12px;
    padding: 4px 10px;
}

#clear-history-btn.remove-btn:hover {
    background-color: rgba(244, 67, 54, 0.1);
}

.history-item {
    padding: 10px;
    border-bottom: 1px solid var(--gray);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: var(--light-gray);
}

/* Custom tooltip element */
.tooltip {
    position: fixed;
    background-color: var(--dark-blue);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: pre-wrap;
    max-width: 80vw;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow);
    opacity: 0.95;
    display: none;
}

.history-item-info {
    flex-grow: 1;
}

.history-item-title {
    font-weight: 500;
    color: var(--dark-blue);
    margin-bottom: 5px;
}

.history-item-date {
    font-size: 12px;
    color: var(--dark-gray);
}

.history-item-cards {
    font-size: 13px;
    color: var(--dark-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.history-item-action {
    display: flex;
    gap: 5px;
}

.history-item-action button {
    padding: 5px 10px;
    font-size: 12px;
    background-color: transparent;
    color: var(--blue);
    border: 1px solid var(--blue);
}

.history-item-action button:hover {
    background-color: var(--blue);
    color: white;
}

.no-history {
    padding: 20px;
    text-align: center;
    color: var(--dark-gray);
    font-style: italic;
}

.deck-name-container {
    margin-bottom: 5px;
}

.deck-name-container label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark-blue);
}

#deck-name-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray);
    border-radius: var(--border-radius);
    transition: border-color 0.3s;
    margin-bottom: 5px;
}

@media (max-width: 768px) {
    .container {
        margin: 10px auto;
        padding: 15px;
        width: 90%;
    }

    h1 {
        font-size: 1.8rem;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-item-action {
        margin-top: 5px;
        align-self: flex-end;
    }

    .history-list {
        max-height: 150px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 12px;
        margin: 8px auto;
    }

    .btn-container {
        flex-direction: column;
        gap: 8px;
    }

    .btn-container button {
        margin: 0;
    }
}

/* Cookie Consent Bar */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--light-blue);
    padding: 15px 30px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    font-size: 14px;
    border-top: 1px solid var(--gray);
}

.cookie-consent-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cookie-emoji {
    font-size: 22px;
}

.cookie-consent-text {
    color: var(--dark-blue);
    font-weight: 500;
    max-width: 80%;
}

.cookie-consent-btn {
    padding: 8px 20px;
    font-weight: 600;
}

/* Scryfall link styles */
.image-link-container {
    text-align: end;
}

.scryfall-link {
    font-size: 12px;
    color: var(--dark-gray);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.scryfall-link:hover {
    opacity: 1;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .cookie-consent {
        flex-direction: column;
        padding: 12px 15px;
        gap: 10px;
    }

    .cookie-consent-text {
        max-width: 100%;
        text-align: center;
    }
}
