* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #2d3561 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    padding: 40px;
    width: 90%;
    max-width: 500px;
    height: 650px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.hidden {
    display: none !important;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-weight: 300;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

input {
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

.link-button {
    background: none;
    color: #667eea;
    text-decoration: underline;
    padding: 10px;
}

.card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin: 15px 10px;
    text-align: center;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s;
    border: 2px solid #eee;
}

.card:hover {
    transform: scale(1.02);
}

.card.flipped {
    background: #e3f2fd;
    border-color: #2196f3;
}

.nav-tabs {
    display: flex;
    margin: 20px 0;
    border-bottom: 3px solid #f0f0f0;
    gap: 0;
}

.nav-tab {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
}

.nav-tab:hover {
    background: #f8f9fa;
    color: #333;
    transform: none;
}

.nav-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #fff;
    font-weight: 500;
}

.nav-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.nav-buttons button {
    flex: 1;
    padding: 10px;
    font-size: 14px;
}

.user-menu {
    position: relative;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.deck-menu {
    position: relative;
    width: 48%;
}

.deck-menu-btn {
    width: 100%;
    padding: 10px 15px;
    background: #e8f5e8;
    border: 2px solid #4caf50;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #2e7d32;
    transition: all 0.3s;
    min-height: 56px;
}

.deck-menu-btn:hover {
    background: #c8e6c9;
    border-color: #388e3c;
}

.deck-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 2px solid #eee;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
}

.settings-menu {
    position: relative;
    width: 48%;
}

.user-menu-btn {
    width: 100%;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 2px solid #eee;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
    transition: all 0.3s;
}

.user-menu-btn:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    background: white;
    border: 2px solid #eee;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    margin-top: 5px;
}

.deck-menu-item, .user-menu-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.deck-menu-item:last-child, .user-menu-item:last-child {
    border-bottom: none;
}

.deck-menu-item:hover, .user-menu-item:hover {
    background: #f8f9fa;
}

.deck-menu-item.active {
    background: #e8f5e8;
    color: #2e7d32;
    font-weight: 500;
}

.deck-menu-separator {
    height: 1px;
    background: #ddd;
    margin: 5px 0;
}

.deck-menu-item.add-deck {
    color: #4caf50;
    font-weight: 500;
}

.deck-menu-item.add-deck:hover {
    background: #e8f5e8;
}

.user-menu-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-menu-item:last-child {
    border-bottom: none;
}

.user-menu-item:hover {
    background: #f8f9fa;
}

.user-menu-item.sign-out {
    color: #dc3545;
}

.user-menu-item.sign-out:hover {
    background: #fff5f5;
}

.add-card-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.add-card-form h3 {
    text-align: center;
}

.add-card-form button {
    display: block;
    margin: 0 auto;
    background: #667eea;
    padding: 8px 15px;
    font-size: 14px;
}

.add-card-form textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    margin-bottom: 15px;
    resize: none;
    height: 100px;
}

#appScreen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#addCardsView, #manageCardsView, #studyView {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 370px;
    flex-shrink: 0;
}

.sort-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    position: relative;
}

.sort-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    position: relative;
}

.filter-input {
    flex: 1;
    padding: 8px 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.filter-input:focus {
    outline: none;
    border-color: #667eea;
}

.sort-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 2px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 180px;
    margin-top: 5px;
}

.sort-option {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
}

.sort-option:last-child {
    border-bottom: none;
}

.sort-option:hover {
    background: #f8f9fa;
}

.sort-option.active {
    background: #e3f2fd;
    color: #2196f3;
    font-weight: 500;
}

.card-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 20px;
    padding-right: 5px;
}

.card-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-content {
    flex: 1;
}

.card-front, .card-back {
    font-size: 14px;
    margin-bottom: 5px;
}

.card-back {
    color: #666;
    font-style: italic;
}

.card-buttons {
    display: flex;
    gap: 8px;
}

.edit-btn {
    background: #2196f3;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
    color: white;
    border: none;
    cursor: pointer;
}

.delete-btn {
    background: #ff4444;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
}

.edit-card-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.edit-card-form textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    margin-bottom: 15px;
    resize: none;
    height: 100px;
}

.edit-buttons {
    display: flex;
    gap: 10px;
}

.edit-buttons button {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.save-btn {
    background: #4caf50;
    color: white;
}

.cancel-btn {
    background: #666;
    color: white;
}

.status {
    text-align: center;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    font-size: 14px;
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 80px);
    max-width: 420px;
    z-index: 10;
}

.status.error {
    background: #ffebee;
    color: #c62828;
}

.status.success {
    background: #e8f5e8;
    color: #2e7d32;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.modal-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.modal-input:focus {
    outline: none;
    border-color: #667eea;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-save {
    background: #4caf50;
    color: white;
}

.modal-save:hover {
    background: #45a049;
}

.modal-cancel {
    background: #666;
    color: white;
}

.modal-cancel:hover {
    background: #555;
}

/* Help Icon Styles */
.help-icon {
    margin-left: auto;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
}

.help-icon:hover {
    opacity: 1;
    background: rgba(103, 126, 234, 0.1);
}

/* Footer Styles */
.app-footer {
    margin-top: auto;
    padding: 12px 0;
    border-top: 1px solid #eee;
    text-align: center;
}

.app-footer a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    transition: opacity 0.2s;
}

.app-footer a:hover {
    opacity: 0.7;
}

/* Modal Close Button (X) */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
    transform: none;
}

.modal {
    position: relative;
}

/* Study Mode Styles */
.no-due-cards {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-due-cards h3 {
    color: #4caf50;
    margin-bottom: 15px;
    font-size: 24px;
}

.no-due-cards p {
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.6;
}

.study-ahead-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.study-ahead-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

.deck-stats-indicator {
    background: #e3f2fd;
    color: #1565c0;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    border: 1px solid #90caf9;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.deck-stats-indicator:hover {
    background: #bbdefb;
}

.study-pace-indicator {
    background: #f3e5f5;
    color: #6a1b9a;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-align: center;
    border: 1px solid #ce93d8;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.study-pace-indicator:hover {
    background: #e1bee7;
}

.study-ahead-indicator {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    border: 1px solid #ffeaa7;
    font-size: 13px;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .user-menu-btn #userEmail {
        display: none;
    }

    .user-menu-btn {
        justify-content: center;
    }

    .app-footer {
        font-size: 12px;
        padding: 12px 10px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .app-footer a {
        font-size: 12px;
    }

    .app-footer span {
        display: none;
    }

    .container {
        height: auto;
        min-height: 650px;
        padding: 30px 20px;
    }
}
