* {
    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;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.login-container h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 28px;
}

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

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

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

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

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease;
    width: 100%;
}

button:hover {
    transform: translateY(-2px);
}

.error-message {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 14px;
}

.dashboard {
    background: white;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

.dashboard header h1 {
    font-size: 24px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
}

.dashboard main {
    padding: 30px;
}

.section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #f9f9f9;
}

.section h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 20px;
}

.section p {
    color: #666;
    line-height: 1.6;
}

#jsonPreview {
    margin-top: 20px;
}

#jsonPreview h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 16px;
}

#jsonContent {
    background: #2d3748;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    overflow-x: auto;
}

.ai-controls, .data-controls {
    margin-bottom: 20px;
}

.ai-controls textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
    resize: vertical;
}

.ai-btn, .data-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    margin-bottom: 10px;
    width: auto;
}

.ai-btn:hover, .data-btn:hover {
    transform: translateY(-1px);
}

.ai-response {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    margin-top: 15px;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.data-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.loading-indicator {
    background: #e3f2fd;
    color: #1976d2;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
    font-style: italic;
}

.themes-table {
    margin-top: 20px;
}

.theme-row {
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    background: #f9f9f9;
}

.theme-row.exists {
    border-color: #ff9800;
    background: #fff3e0;
}

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

.theme-name {
    font-weight: bold;
    font-size: 18px;
    color: #333;
}

.theme-status {
    background: #ff9800;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.theme-words {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border: 1px solid #eee;
}

.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.word-tag {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.existing-words {
    margin-top: 10px;
    padding: 10px;
    background: #ffecb3;
    border-radius: 5px;
    border: 1px solid #ffc107;
}

.existing-words h4 {
    margin: 0 0 8px 0;
    color: #e65100;
}

.theme-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.add-theme-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.add-theme-btn:hover {
    background: #45a049;
}

.add-theme-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.global-actions {
    margin: 20px 0;
    text-align: center;
}

.add-all-btn {
    background: #2196f3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.add-all-btn:hover {
    background: #1976d2;
}


@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    .login-container {
        padding: 30px 20px;
    }
    
    .dashboard main {
        padding: 20px;
    }
    
    .data-controls {
        flex-direction: column;
    }
    
    .ai-btn, .data-btn {
        width: 100%;
        margin-right: 0;
    }
}

/* Edit Mode Styles */
.edit-mode {
    background: #f8f9fa;
    border-left: 4px solid #007bff;
}

.theme-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 20px;
    transition: all 0.3s ease;
}

.theme-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.theme-header-edit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.theme-title-edit {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

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

.edit-btn, .save-btn, .cancel-btn, .delete-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.edit-btn {
    background: #007bff;
    color: white;
}

.edit-btn:hover {
    background: #0056b3;
}

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

.save-btn:hover {
    background: #1e7e34;
}

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

.cancel-btn:hover {
    background: #545b62;
}

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

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

.theme-words-container {
    margin-top: 15px;
}

.words-input {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    resize: vertical;
}

.words-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.word-chip {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    border: 1px solid #dee2e6;
}

.json-view {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.theme-name-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
}

.themes-display {
    background: #f8f9fa;
    border-left: 4px solid #28a745;
    padding: 10px;
}

.theme-word-count {
    color: #6c757d;
    font-size: 14px;
    font-weight: normal;
}