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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2563eb;
    color: #333;
    min-height: 100vh;
    padding-top: 80px; /* Space for fixed navbar */
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.app-header h1 {
    font-size: 42px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.app-header .subtitle {
    font-size: 18px;
    opacity: 0.9;
}

/* Login Reminder */
.login-reminder {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    color: #856404;
}

.login-reminder a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-top: 20px;
}

/* Left Panel */
.left-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 20px;
}

.panel-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 20px;
}

.set-management {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

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

.set-item {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.set-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.set-item.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.set-item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.set-item-stats {
    font-size: 14px;
    color: #666;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Right Panel */
.right-panel {
    background: white;
    min-width: 0; /* Allow flex shrinking */
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 500px;
    width: 100%;
}

/* When sidebar is hidden, center the right panel content */
.main-content.sidebar-hidden {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0;
}

.main-content.sidebar-hidden .right-panel {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    justify-self: center;
}

/* Main Sets List View */
.sets-list-view {
    width: 100%;
}

.main-sets-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.main-set-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.main-set-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-5px);
}

.main-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.main-set-name {
    color: #667eea;
    font-size: 20px;
    margin: 0;
}

.main-set-stats {
    color: #666;
    font-size: 14px;
}

.main-set-description {
    color: #666;
    font-size: 14px;
    margin: 10px 0;
    line-height: 1.5;
}

.main-set-progress {
    margin-top: 15px;
}

.set-info {
    margin-bottom: 30px;
}

.set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.set-header h2 {
    color: #667eea;
    font-size: 28px;
}

.set-stats {
    color: #666;
    font-size: 16px;
}

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

/* Learning Mode */
.learning-mode {
    text-align: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.flashcard-container {
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

.flashcard {
    width: 100%;
    max-width: 600px;
    height: 400px;
    margin: 0 auto 20px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.flashcard.locked {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.9;
}

.flashcard:not(.locked) {
    cursor: pointer;
}

.flashcard.slide-out-left {
    animation: slideOutLeft 0.4s ease-in-out forwards;
}

.flashcard.slide-out-right {
    animation: slideOutRight 0.4s ease-in-out forwards;
}

.flashcard.slide-in-left {
    animation: slideInLeft 0.4s ease-in-out forwards;
}

.flashcard.slide-in-right {
    animation: slideInRight 0.4s ease-in-out forwards;
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.flashcard-front {
    background: #667eea;
    color: white;
}

.flashcard-back {
    background: #4facfe;
    color: white;
    transform: rotateY(180deg);
}

.card-label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-content {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.card-example {
    margin-top: 20px;
    font-size: 18px;
    font-style: italic;
    opacity: 0.9;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.flashcard-progress {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    max-width: 600px;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    margin: 0 auto 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #667eea;
    transition: width 0.3s;
    border-radius: 5px;
}

.flashcard-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* Review Mode specific button styles */
#reviewMode .flashcard-actions {
    gap: 30px;
    margin-top: 40px;
}

#reviewMode .flashcard-actions .btn {
    padding: 18px 40px;
    font-size: 18px;
    min-width: 180px;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#reviewMode .flashcard-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#reviewMode .flashcard-actions .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Learn Mode button styling */
#learningMode .flashcard-actions {
    gap: 20px;
}

#learningMode .flashcard-actions .btn {
    padding: 15px 35px;
    font-size: 16px;
    min-width: 160px;
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state h3 {
    font-size: 28px;
    margin-bottom: 15px;
    color: #667eea;
}

.empty-state p {
    font-size: 16px;
    line-height: 1.6;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

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

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 900px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Hint Modal Styling */
.hint-modal-content {
    max-width: 500px;
    text-align: center;
}

.hint-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.hint-icon {
    font-size: 48px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.hint-header h2 {
    margin: 0;
    color: #667eea;
    font-size: 28px;
    font-weight: 600;
}

.hint-body {
    padding: 30px 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hint-text {
    font-size: 18px;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #ffc107;
    word-wrap: break-word;
    max-width: 100%;
}

.hint-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.hint-footer .btn {
    min-width: 150px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.words-list-container {
    margin-top: 30px;
}

.words-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin: 20px 0;
    max-height: 400px; /* Limit to approximately 2 rows */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Space for scrollbar */
}


.word-item {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.word-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.word-item-name {
    font-weight: 600;
    color: #667eea;
    font-size: 18px;
}

.word-item-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #e0e0e0;
}

.word-item-status.known {
    background: #d4edda;
    color: #155724;
}

.word-item-status.review {
    background: #fff3cd;
    color: #856404;
}

.word-item-status.unknown {
    background: #f8d7da;
    color: #721c24;
}

.word-item-definition {
    color: #666;
    margin-bottom: 8px;
}

.word-item-example {
    font-style: italic;
    color: #999;
    font-size: 14px;
}

.word-item-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.status-message {
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    display: none;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding-top: 120px;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .left-panel {
        max-height: none;
    }

    .flashcard {
        height: 300px;
    }

    .card-content {
        font-size: 28px;
    }

    .flashcard-actions {
        flex-direction: column;
    }

    .flashcard-actions .btn {
        width: 100%;
    }
}

/* AI Analysis Panel Styles */
/* AI Analysis Panel - Outside grid, fixed overlay */
.ai-analysis-panel {
    display: none;
    position: fixed;
    right: 0;
    top: 80px;
    width: 320px;
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
}

/* Don't add margin - let AI panel overlay without affecting layout */
.main-content.ai-analysis-active .right-panel {
    /* No margin - panel overlays on top */
}

.ai-analysis-panel.active {
    display: flex;
}

.ai-analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
}

.ai-analysis-header h3 {
    margin: 0;
    color: #667eea;
    font-size: 16px;
}

.ai-analysis-reload {
    background: none;
    border: none;
    font-size: 20px;
    color: #667eea;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s;
}

.ai-analysis-reload:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: rotate(180deg);
}

.ai-analysis-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: background 0.2s;
}

.ai-analysis-close:hover {
    background: #e0e0e0;
}

.ai-analysis-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    font-size: 14px;
}

.ai-analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-word-analysis {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    line-height: 1.5;
    font-size: 13px;
}

.ai-word-analysis h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 16px;
}

.ai-word-analysis p,
.ai-word-analysis ul {
    margin: 8px 0;
    color: #333;
}

.ai-word-analysis strong {
    color: #667eea;
}

.ai-hints-section {
    margin-top: 20px;
}

.ai-hints-section h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 14px;
}

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

.ai-hint-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
}

.ai-hint-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.ai-hint-text {
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
    font-size: 13px;
}

.ai-hint-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    width: 100%;
}

.ai-hint-button:hover {
    background: #5568d3;
}

.ai-hint-button:active {
    background: #4457c2;
}

.ai-analysis-error {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    color: #856404;
    text-align: center;
}

.btn-info {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-info:active {
    transform: translateY(0);
}

/* Responsive styles for AI panel */
@media (max-width: 1200px) {
    /* On smaller screens, reduce panel width */
    .ai-analysis-panel {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .ai-analysis-panel {
        width: 100%;
        right: 0;
        left: 0;
        height: 50vh;
        top: auto;
        bottom: 0;
        border-radius: 10px 10px 0 0;
    }
    
    /* No margin needed - panel overlays as bottom sheet */
}

/* Grouping Notes Styles */
#groupingNotesText {
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

.notes-heading {
    margin-top: 24px;
    margin-bottom: 12px;
    color: #667eea;
    font-weight: 600;
}

.notes-heading:first-child {
    margin-top: 0;
}

.notes-paragraph {
    margin: 12px 0;
    line-height: 1.8;
}

.notes-list {
    margin: 12px 0;
    padding-left: 24px;
}

.notes-list-item {
    margin: 6px 0;
    line-height: 1.6;
}

/* Grouping Notes Table Styles */
.grouping-notes-table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    background: white;
    font-size: 14px;
    border: 2px solid #d1d5db;
}

/* First row styling (header row, but as td) */
.grouping-notes-table tbody tr:first-child td {
    background: white;
    color: #1f2937;
    padding: 12px 16px;
    text-align: left;
    font-weight: 400;
    font-size: 14px;
    border-bottom: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
}


.grouping-notes-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
    vertical-align: top;
    line-height: 1.6;
}

.grouping-notes-table td:first-child {
    font-weight: normal;
}

.grouping-notes-table td:last-child {
    border-right: none;
}

.grouping-notes-table tr:last-child td {
    border-bottom: 2px solid #d1d5db;
}

.grouping-notes-table tbody tr {
    border-left: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
}

.grouping-notes-table tbody tr:first-child {
    border-top: 1px solid #d1d5db;
}

.grouping-notes-table tbody tr:last-child {
    border-bottom: 2px solid #d1d5db;
}


.grouping-notes-table tbody {
    border-left: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
}

/* LaTeX Rendering Styles */
.latex-display {
    display: block;
    margin: 15px 0;
    text-align: center;
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
}

.latex-inline {
    display: inline;
    padding: 2px 4px;
}

#groupingNotesText {
    overflow-x: auto;
}

