/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #6d816e 0%, #2bfd18 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Typography */
h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h3 {
    margin-bottom: 15px;
    color: #333;
}

/* Form Elements */
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* Language Selection */
.language-selection {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.language-selection h3 {
    margin: 0;
    color: #333;
}

.language-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.language-tab {
    background: white;
    border: 2px solid #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-tab:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.language-tab.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.add-language-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.add-language-input {
    width: 150px;
    margin: 0;
    font-size: 14px;
    padding: 8px 12px;
}

.add-language-btn {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
}

/* Card Sections */
.category-control {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.category-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.add-word-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.add-word-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.search-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

/* Toggle Switch */
.category-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 25px;
    background: #ddd;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch.active {
    background: #667eea;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(25px);
}

/* Manual Mode */
.manual-mode {
    display: none;
}

.manual-mode.active {
    display: block;
}

.category-inputs {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: end;
}

/* Statistics */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.category-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 2px solid #f0f0f0;
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
    animation: fadeIn 0.5s ease-out;
}

.category-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.category-card.hidden {
    opacity: 0;
    transform: scale(0.8);
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.category-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
    text-transform: capitalize;
    border-bottom: 3px solid #667eea;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Add after the existing .category-title styles */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.category-title {
    margin: 0;
    border-bottom: 3px solid #667eea;
    padding-bottom: 8px;
    flex: 1;
}

.category-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Replace move control styles with drag handle styles */
.drag-handle {
    cursor: grab;
    color: #6c757d;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: all 0.2s ease;
}

.drag-handle:hover {
    color: #495057;
    background: rgba(108, 117, 125, 0.1);
    border-radius: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.dots {
    font-size: 14px;
    line-height: 1;
    letter-spacing: -2px;
}

.category-drag .dots {
    font-size: 16px;
}

.word-drag {
    margin-right: 10px;
}

/* Drag feedback styles */
.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
}

.drag-over-top {
    border-top: 3px solid #667eea;
}

.drag-over-bottom {
    border-bottom: 3px solid #667eea;
}

/* Update word-item layout */
.word-item {
    background: #f8f9fa;
    margin-bottom: 8px;
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.word-content {
    flex: 1;
}

.delete-word {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.8rem;
    cursor: pointer;
    width: auto;
}

/* Update category header */
.category-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Update word-item styles */
.word-item {
    background: #f8f9fa;
    margin-bottom: 8px;
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .category-controls {
        align-self: flex-end;
    }
    
    .move-controls {
        flex-direction: column;
        gap: 2px;
    }
    
    .word-controls {
        flex-direction: column;
        gap: 5px;
    }
}

/* Word List */
.word-list {
    list-style: none;
}

.word-item {
    background: #f8f9fa;
    margin-bottom: 8px;
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.word-content {
    flex: 1;
}

.foreign-word {
    font-weight: bold;
    color: #333;
}

.english-meaning {
    color: #666;
    font-style: italic;
}

/* Delete Buttons */
.delete-category {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    width: auto;
}

.delete-category:hover {
    background: #c82333;
    transform: none;
    box-shadow: none;
}

.delete-word {
    background: #dc3545;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    width: auto;
    margin-left: 10px;
}

.delete-word:hover {
    background: #c82333;
    transform: none;
    box-shadow: none;
}

.delete-language {
    background: #dc3545;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    width: auto;
    margin-left: 5px;
}

.delete-language:hover {
    background: #c82333;
    transform: none;
    box-shadow: none;
}

/* Export/Import Buttons */
.export-import {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.export-import button {
    font-size: 0.9rem;
    padding: 8px 12px;
}

/* Save Indicator */
.save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Info Banner */
.local-storage-info {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid #28a745;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    color: #155724;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
    }
    
    .category-inputs {
        grid-template-columns: 1fr;
    }
    
    .export-import {
        grid-template-columns: 1fr;
    }
    
    .stats {
        flex-direction: column;
        align-items: center;
    }

    .language-selection {
        flex-direction: column;
        align-items: flex-start;
    }

    .language-tabs {
        width: 100%;
    }

    .add-language-section {
        width: 100%;
    }
}