:root {
    --font-family-body: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI',
                        Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue',
                        sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}

body {
    font-family: var(--font-family-body);
}

button, select{
    font-family:  var(--font-family-body);
}

.ql-editor p {
    font-family: var(--font-family-body);
}

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

#front-editor, #back-editor {
    height: 200px;
    margin-bottom: 20px;
}

.submit-btn {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.submit-btn:hover {
    background-color: #45a049;
}

.ql-editor {
    min-height: 150px;
}

.navigation {
    margin-bottom: 0;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.nav-link {
    margin-right: 15px;
    text-decoration: none;
    color: #333;
    padding: 5px 10px;
    border-radius: 4px;
}

.nav-link:hover {
    background-color: #f0f0f0;
}

.card {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    margin-bottom: 20px;
}

/* Ensure single-card view is a positioned container so absolute icons align */
.card {
    position: relative;
}

.card-front, .card-back {
    max-width: 100%;
    overflow-x: auto; /* Allow horizontal scroll if content is too wide */
    word-wrap: break-word; /* Break long words */
}

/* Style for Quill content inside cards */
.card .ql-editor {
    padding: 0;
    max-width: 100%;
}

/* Ensure images don't overflow */
.card img {
    max-width: 100%;
    height: auto;
}

/* Ensure code blocks don't overflow */
.card pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Ensure tables don't overflow */
.card table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

.front, .back {
    margin-bottom: 20px;
    font-size: 1.1em;
    line-height: 1.5;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 8px;
}

a.btn{
    text-decoration: none;
}

button.interval-btn{
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 8px;
    background-color: #4CAF50;
    color: white;
}

.interval-btn:hover {
    background-color: #45a049;
}

.interval-buttons {
    margin-top: 10px;
}

.edit-btn {
    background-color: #2196F3;
    color: white;
}

.card-item .card-actions {
    float: left;
    margin-right: 20px;
}

.card-item {
    border: 1px solid #ddd;
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 4px;
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    position: relative;
}

.card-icons {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

.icon-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #888;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.icon-btn:hover {
    color: #2196F3;
}

.edit-icon svg {
    stroke: #2196F3;
}
.delete-icon svg {
    stroke: #f44336;
}

.card-preview {
    margin-bottom: 10px;
    max-width: 100%;
    box-sizing: border-box;
}

.preview-front {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    padding: 10px;
}

.preview-back {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.show-btn {
    background-color: #28a745;
    color: white;
}

.show-btn:hover {
    background-color: #218838;
}

.no-cards {
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    border-radius: 8px;
}

.card-actions {
    display: flex;
    gap: 10px;
}

.search-stats-wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 5px;
}

.search-container {
    flex: 1;
    margin-right: 400px;
}

.search-stats-wrapper .stats {
    margin: 0;
    border-radius: 4px;
    white-space: nowrap;
}

.stats {
    text-align: right;
}

.card-history {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 0.9em;
    color: #666;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.search-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,.25);
}

.page-header {
    margin: 20px 0 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    clear: both;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.form-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
}

.cancel-btn {
    background-color: #6c757d;
    color: white;
}

.cancel-btn:hover {
    background-color: #5a6268;
}

#front-editor, #back-editor {
    margin-bottom: 30px;
    border-radius: 4px;
}

.ql-toolbar {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.ql-container {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    font-size: 15px;
    height: 500px !important;
}

.auth-form {
    max-width: 400px;
    margin: 40px auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.auth-form h1 {
    text-align: center;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
}

.error-message {
    color: #f44336;
    padding: 10px;
    margin-bottom: 15px;
    background: #ffebee;
    border-radius: 4px;
    text-align: center;
}

.deck-management {
    max-width: 800px;
    margin: 20px auto;
}

.deck-form {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.deck-form input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.deck-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deck-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.deck-item.selected {
    background: #e3f2fd;
}

.deck-edit-form {
    flex: 1;
    display: flex;
    gap: 10px;
}

.deck-edit-form input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.select-btn {
    background-color: #2196F3;
}

.btn:hover {
    opacity: 0.9;
}

.flash-message {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    text-align: center;
}

.flash-message.success {
    color: #4CAF50;
    background: #E8F5E9;
}

.flash-message.error {
    color: #f44336;
    background: #ffebee;
}

.front-input {
    width: calc(100% - 2px); /* Match Quill editor width */
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    margin-bottom: 20px;
    height: 45px; /* Fixed height for single line */
}

.front-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.deck-selector {
    margin: 10px 0;
    margin-bottom: 20px;
    text-align: right;
}

.deck-selector select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    width: 200px;
    cursor: pointer;
}

.deck-selector select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Ensure proper spacing after navigation */
.navigation::after {
    content: "";
    display: table;
    clear: both;
    margin-bottom: 10px;
}

/* Stats styling for list page */
.search-stats-wrapper .stats {
    clear: none;
}

.deck-stats {
    margin: 0 10px;
    color: #666;
}

.deck-stats span {
    margin-right: 15px;
}

.deck-stats strong {
    color: #2196F3;
}

.interval-btn.current {
    background-color: #ffd700;
    color: black;
}

.edit-intervals {
    margin: 20px 0;
    display: block;
}

.edit-intervals .interval-btn {
    margin-bottom: 10px;
}

/* For edit page */
#flashcard-form .interval-buttons {
    margin: 20px 0;
    display: block;
}

/* For review page */
.card .interval-buttons {
    display: none; /* Initially hidden until answer is shown */
}

/* Update scope switcher styles */
.scope-switcher {
    margin: 10px 0;
}

/* Add clearfix after the switchers */
.switchers-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.scope-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
}

.scope-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.scope-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.scope-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Common styles for card content (both preview and back) */
.preview-front, .preview-back {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
}

/* Style for Quill content */
.preview-front .ql-editor,
.preview-back .ql-editor {
    padding: 0;
    max-width: 100%;
}

/* Ensure images don't overflow */
.preview-front img,
.preview-back img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}

/* Ensure code blocks don't overflow */
.preview-front pre,
.preview-back pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 4px;
}

/* Ensure tables don't overflow */
.preview-front table,
.preview-back table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
    border-collapse: collapse;
    margin: 10px 0;
}

/* Table styles */
.preview-front td,
.preview-front th,
.preview-back td,
.preview-back th {
    border: 1px solid #ddd;
    padding: 8px;
}

/* Quill editor text size styles */
.ql-size-small {
    font-size: 0.75em;
}

.ql-size-large {
    font-size: 1.5em;
}

.ql-size-huge {
    font-size: 2.5em;
}