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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 6px 15px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9em;
}

nav a:hover,
nav a.active {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Main Content */
main {
    padding: 15px;
    min-height: 300px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h2 {
    color: #333;
    font-size: 1.5em;
}

.back-link {
    color: #667eea;
    text-decoration: none;
    font-size: 0.95em;
    margin-bottom: 5px;
    display: inline-block;
}

.back-link:hover {
    text-decoration: underline;
}

/* Search Section */
.search-section {
    margin-bottom: 15px;
}

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.95em;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-edit,
.btn-delete,
.btn-add-collection {
    padding: 6px 15px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.9em;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    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-edit {
    background: #28a745;
    color: white;
    padding: 5px 12px;
    font-size: 0.85em;
}

.btn-edit:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 5px 12px;
    font-size: 0.85em;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-add-collection {
    background: #17a2b8;
    color: white;
    padding: 6px 12px;
    font-size: 0.85em;
    width: 100%;
    text-align: center;
}

.btn-add-collection:hover {
    background: #138496;
}

/* Stats */
.stats {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.stats p {
    color: #666;
    font-size: 0.95em;
}

.stats strong {
    color: #667eea;
    font-size: 1em;
}

/* Words Grid */
.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.word-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    transition: all 0.3s ease;
}

.word-card:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

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

.word-header h2 {
    color: #333;
    font-size: 1.2em;
    flex: 1;
}

.word-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.meanings {
    margin-bottom: 10px;
}

.meaning-section {
    margin-bottom: 6px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.label {
    font-weight: bold;
    color: #667eea;
    margin-right: 6px;
    font-size: 0.85em;
}

.meaning {
    color: #333;
    font-size: 0.95em;
}

.example {
    background: #fff3cd;
    padding: 8px 10px;
    border-radius: 4px;
    border-left: 3px solid #ffc107;
    margin-bottom: 10px;
}

.example p {
    color: #856404;
    font-style: italic;
    margin-top: 3px;
    font-size: 0.9em;
}

.word-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.category-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 6px;
    padding: 15px;
    transition: all 0.3s ease;
}

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

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

.category-header h3 {
    color: #333;
    font-size: 1.2em;
}

.word-count {
    background: #667eea;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.category-description {
    color: #555;
    margin-bottom: 12px;
    line-height: 1.4;
    font-size: 0.9em;
}

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

/* Forms */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-container h2 {
    color: #333;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.5em;
}

.word-form,
.collection-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
}

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

.form-group label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.95em;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.collection-list {
    background: white;
    border-radius: 5px;
    padding: 10px;
}

.collection-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 6px;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.collection-item:hover {
    background: #e9ecef;
}

.collection-item input[type="radio"] {
    margin-right: 10px;
}

.collection-item input[type="radio"]:disabled {
    cursor: not-allowed;
}

.collection-item em {
    color: #6c757d;
    font-size: 0.85em;
    margin-left: 8px;
}

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

/* Alerts */
.alert {
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 12px;
    font-weight: 500;
    font-size: 0.9em;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 3px solid #28a745;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 3px solid #dc3545;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 6px;
    color: #6c757d;
}

.no-results p {
    font-size: 1em;
}

.no-results a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.no-results a:hover {
    text-decoration: underline;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.page-info {
    color: #666;
    font-weight: 500;
    font-size: 0.9em;
}

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

.modal-content {
    background: white;
    margin: 30px auto;
    border-radius: 8px;
    max-width: 600px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: all 0.3s ease;
}

.close:hover {
    transform: scale(1.1);
}

.modal-content form {
    padding: 20px;
}

/* Footer */
footer {
    background: #f8f9fa;
    text-align: center;
    padding: 12px;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    font-size: 0.9em;
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 30px;
    color: #667eea;
}

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

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

/* Speech Buttons */
.btn-speak {
    background: transparent;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px 8px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    margin-left: 8px;
    opacity: 0.7;
}

.btn-speak:hover {
    transform: scale(1.2);
    opacity: 1;
}

.btn-speak:active {
    transform: scale(1.1);
    opacity: 0.8;
}

.btn-speak-mini {
    background: transparent;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
    padding: 2px 5px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    margin-left: 5px;
    opacity: 0.6;
}

.btn-speak-mini:hover {
    transform: scale(1.15);
    opacity: 1;
}

.btn-speak-mini:active {
    transform: scale(1.05);
    opacity: 0.8;
}

.word-title-section {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.meaning-header,
.example-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

/* Bulk Upload & Export Styles */
.upload-section {
    max-width: 900px;
    margin: 0 auto;
}

.upload-instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.upload-instructions h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.upload-instructions h4 {
    color: #333;
    margin-top: 15px;
    margin-bottom: 10px;
}

.upload-instructions ol,
.upload-instructions ul {
    margin-left: 20px;
    line-height: 1.8;
}

.download-section {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.upload-form-container {
    background: white;
    border: 2px dashed #667eea;
    border-radius: 6px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
}

.upload-form-container h3 {
    color: #333;
    margin-bottom: 20px;
}

.file-input-wrapper {
    margin-bottom: 20px;
}

.file-label {
    display: inline-block;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

.file-icon {
    font-size: 1.2em;
    margin-right: 8px;
}

input[type="file"] {
    display: none;
}

.upload-form .form-actions {
    justify-content: center;
}

.error-details {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
}

.error-details h3 {
    color: #856404;
    margin-bottom: 10px;
}

.error-details ul {
    margin-left: 20px;
    color: #856404;
}

.error-details li {
    margin-bottom: 5px;
}

.btn-export {
    background: #28a745;
    color: white;
    padding: 6px 15px;
    border-radius: 15px;
    text-decoration: none;
    display: inline-block;
    font-size: 0.9em;
    transition: all 0.3s ease;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

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

.export-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}


/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5em;
    }

    .words-grid,
    .categories-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    nav {
        flex-direction: column;
        width: 100%;
    }

    nav a {
        width: 100%;
        text-align: center;
    }

    .search-form {
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .word-header {
        flex-direction: column;
    }

    .word-actions {
        width: 100%;
    }

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

    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
    }

    .modal-content {
        margin: 20px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    main {
        padding: 10px;
    }

    header {
        padding: 12px 10px;
    }

    .word-card,
    .category-card {
        padding: 10px;
    }

    .word-form,
    .collection-form {
        padding: 15px;
    }
}
