/* Flashcard Study Mode Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    overflow: auto;
    transition: background-color 0.3s ease;
}

.modal-content {
    background-color: var(--modal-content-bg);
    margin: 5% auto;
    padding: 40px 30px 30px;
    border-radius: 10px;
    width: 80%;
    max-width: 700px;
    box-shadow: var(--card-shadow);
    position: relative;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--card-border);
}

.close-button {
    position: absolute;
    top: 0px;
    right: 5px;
    color: var(--close-button-text);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.3s ease;
    border-radius: 50%;
    z-index: 1001; /* Ensure it's above other elements */
}

.close-button:hover {
    color: var(--close-button-hover);
}

.study-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.study-controls button {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s ease;
}

.study-controls button:hover {
    background-color: var(--button-hover);
}

/* Toggle Controls Container */
.toggle-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 15px 0;
    padding-left: 20px;
}

/* Toggle Row */
.toggle-row {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    gap: 30px;
}

/* Toggle Group */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-label {
    font-size: 14px;
    color: var(--card-back-text);
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4682b4; /* Portuguese mode color (steel blue) */
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #3cb371; /* English mode color (medium sea green) */
}

/* Orange slider for card side toggle */
.slider.orange {
    background-color: #6495ED; /* Front side color (cornflower blue) */
}

input:checked + .slider.orange {
    background-color: #FF8C00; /* Back side color (dark orange) */
}

input:focus + .slider {
    box-shadow: 0 0 1px #3cb371;
}

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

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Hover style already defined above */

.arrow {
    border: solid var(--button-text);
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 3px;
    transition: border-color 0.3s ease;
}

.right {
    transform: rotate(-45deg);
}

.left {
    transform: rotate(135deg);
}

.flashcard {
    perspective: 1000px;
    height: 350px;
    margin: 30px 0;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    padding: 20px;
    box-sizing: border-box;
}

.flashcard-front {
    background: var(--card-front-bg);
    color: var(--card-front-text);
    transition: background 0.3s ease, color 0.3s ease;
}

.flashcard-back {
    background-color: var(--card-back-bg);
    color: var(--card-back-text);
    transform: rotateY(180deg);
    border: 2px solid var(--card-back-border);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.flashcard-back .english {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--card-back-text);
    transition: color 0.3s ease;
}

.flashcard-back .example,
.flashcard-back .card-example-english {
    font-style: italic;
    margin: 8px 0;
    padding: 8px 15px;
    border-radius: 8px;
    width: 90%; /* Match the width of other elements in the card */
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.flashcard-back .example {
    background-color: var(--example-bg);
    color: var(--example-text);
    border-left: 4px solid #4682b4; /* Steel blue border */
    display: inline-block;
    max-width: fit-content;
}

.flashcard-back .card-example-english {
    background-color: var(--example-english-bg);
    color: var(--example-english-text);
    border-left: 4px solid #3cb371; /* Medium sea green border */
    display: inline-block;
    max-width: fit-content;
}

.flashcard-back .meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    margin-top: 15px;
}

.flashcard-back .part-of-speech {
    background-color: var(--part-of-speech-bg);
    color: var(--part-of-speech-text);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    display: inline-block;
    margin: 5px 0;
}

.flashcard-back .difficulty {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: bold;
    display: inline-block;
    margin: 5px 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.flashcard-back .tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.flashcard-back .tag {
    background-color: var(--tag-bg);
    color: var(--tag-text);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    display: inline-block;
    margin: 2px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card-example {
    margin: 20px 0;
    font-style: italic;
    max-width: 80%;
    padding: 10px;
    background-color: var(--example-bg);
    color: var(--example-text);
    border-left: 3px solid var(--card-back-border);
    border-radius: 3px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.study-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    color: var(--card-back-text);
    opacity: 0.8;
    font-size: 14px;
    transition: color 0.3s ease;
}

.keyboard-shortcuts {
    font-style: italic;
}

/* Make regular cards clickable */
.card {
    cursor: pointer;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
