* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --success-color: #2ecc71;
    --success-dark: #27ae60;
    --danger-color: #e74c3c;
    --danger-dark: #c0392b;
    --text-color: #2c3e50;
    --secondary-text: #7f8c8d;
    --bg-color: #f5f5f5;
    --card-bg: white;
    --border-color: #eee;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Mobile-first Navigation */
.top-nav {
    background-color: var(--primary-color);
    color: white;
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.nav-logo {
    font-size: 1.2rem;
    font-weight: bold;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: block;
}

.nav-menu {
    list-style: none;
    display: none;
    width: 100%;
    margin-top: 1rem;
    flex-direction: column;
}

.nav-menu.active {
    display: flex;
}

.nav-menu li {
    padding: 0.5rem 0;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    display: block;
    padding: 0.5rem 0;
    transition: 0.3s;
}

.nav-menu a:hover, .nav-menu a.active {
    opacity: 0.8;
}

/* Container and General Styling */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
}

h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

/* Voice Section */
.voice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

#status {
    margin-bottom: 1rem;
    text-align: center;
}

#mic-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#mic-button:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

#mic-button.listening {
    background-color: var(--danger-color);
    animation: pulse 1.5s infinite;
}

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

.word-display {
    font-size: 2rem;
    font-weight: bold;
    margin: 1rem 0;
    min-height: 3rem;
    color: var(--text-color);
}

/* Definition Container */
.definition-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    min-height: 150px;
    position: relative;
}

.definition-display {
    line-height: 1.6;
}

.definition-display h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.definition-display p {
    margin-bottom: 1rem;
}

.definition-display .part-of-speech {
    font-style: italic;
    color: var(--secondary-text);
    margin-right: 0.5rem;
}

/* History Section */
.history-section {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.history-list {
    margin-top: 1rem;
}

.history-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.history-item:hover {
    background-color: #f9f9f9;
}

.history-item h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.history-item {
    position: relative;
}

.history-item h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-definition {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    margin-top: 0.5rem;
}

.history-item-definition.expanded {
    max-height: 500px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.history-item-definition .close-btn {
    float: right;
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.5rem;
}

.history-item-actions {
    display: none;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.history-item:hover .history-item-actions {
    display: flex;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.pagination-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.pagination-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#page-info {
    font-size: 0.9rem;
    color: var(--secondary-text);
}

.delete-word {
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.delete-word:hover {
    background-color: var(--danger-dark);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-container {
    display: none; /* Changed from none !important to allow JavaScript to control visibility */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 10;
    border-radius: 8px;
}

.loading-container.visible {
    display: flex !important;
}

.loading-text {
    margin-top: 10px;
    color: var(--secondary-text);
    font-weight: bold;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.action-button.accept {
    background-color: var(--success-color);
    color: white;
}

.action-button.accept:hover {
    background-color: var(--success-dark);
}

.action-button.reject {
    background-color: var(--danger-color);
    color: white;
}

.action-button.reject:hover {
    background-color: var(--danger-dark);
}

/* Settings Section */
.settings-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.setting-item {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.setting-item label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.setting-item select, .setting-item input[type="text"] {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
}

.secondary-btn {
    background-color: #7f8c8d;
    color: white;
}

.secondary-btn:hover {
    background-color: #6c7a7b;
}

.danger-btn {
    background-color: var(--danger-color);
    color: white;
}

.danger-btn:hover {
    background-color: var(--danger-dark);
}

.data-management {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.data-management h3 {
    margin-bottom: 1rem;
}

.data-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.hidden {
    display: none !important;
}

/* Dark Theme */
body.dark-theme {
    --bg-color: #1a1a1a;
    --card-bg: #2a2a2a;
    --text-color: #f5f5f5;
    --secondary-text: #bbb;
    --border-color: #444;
}

body.dark-theme .history-item:hover {
    background-color: #333;
}

body.dark-theme .loading-container {
    background-color: rgba(42, 42, 42, 0.8);
}

/* Desktop styles */
@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex;
        width: auto;
        margin-top: 0;
        flex-direction: row;
    }
    
    .nav-menu li {
        padding: 0;
        margin-left: 1.5rem;
    }
    
    .nav-menu a {
        padding: 0;
    }
    
    .container {
        padding: 2rem;
    }
}