* {
    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: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header Styles */
.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-content h1 {
    color: #764ba2;
    font-size: 32px;
    margin-bottom: 8px;
    font-weight: 700;
}

.header-content h1 i {
    margin-left: 10px;
    color: #667eea;
}

.header-content p {
    color: #666;
    font-size: 16px;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.card-header h3 i {
    margin-left: 10px;
}

.card-body {
    padding: 30px;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

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

/* File Upload */
.file-upload {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    padding: 12px 15px;
    border: 2px dashed #e0e0e0;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
}

.file-upload-label:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.file-upload-label i {
    margin-left: 8px;
    color: #667eea;
}

/* Image Preview */
.image-preview {
    margin-top: 10px;
    display: none;
}

.image-preview img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

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

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

.btn-warning {
    background: #ffc107;
    color: #212529;
}

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

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

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

.btn-back {
    background: #361e52;
    color: white;
}

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

.btn-refresh {
    background: #17a2b8;
    color: white;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* Category Icon in Table */
.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid #e0e0e0;
}

.no-icon {
    width: 40px;
    height: 40px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    border: 2px dashed #e0e0e0;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Alert Messages */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    animation: slideDown 0.3s;
}

.alert.show {
    display: block;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error Messages */
.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 40px;
    display: none;
}

.loading-state.show {
    display: block;
}

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

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.empty-state.show {
    display: block;
}

.empty-state i {
    font-size: 64px;
    color: #6c757d;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}

.empty-state p {
    color: #666;
    font-size: 16px;
}

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

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #dc3545;
    font-size: 20px;
}

.modal-header h3 i {
    margin-left: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

.modal-actions {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.text-warning {
    color: #856404;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .card-body {
        padding: 20px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header-content h1 {
        font-size: 24px;
    }
}

/* Badge Styles */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.level-0 { background: #e3f2fd; color: #1976d2; }
.level-1 { background: #f3e5f5; color: #7b1fa2; }
.level-2 { background: #e8f5e8; color: #388e3c; }

/* Select Styles */
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    background: white;
    cursor: pointer;
}

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

/* Form Validation */
.form-group input:invalid,
.form-group select:invalid {
    border-color: #dc3545;
}

.form-group input:valid,
.form-group select:valid {
    border-color: #28a745;
}

/* Tree View Styles */
.tree-view {
    margin-bottom: 20px;
}

.tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-item {
    margin: 5px 0;
}

.tree-node {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 2px 0;
    transition: all 0.3s;
}

.tree-node:hover {
    background: #e9ecef;
}

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.3s;
}

.tree-toggle.has-children {
    color: #667eea;
}

.tree-toggle:not(.has-children) {
    visibility: hidden;
}

.tree-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    margin-left: 10px;
}

.tree-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tree-content small {
    color: #666;
    font-family: Arial, sans-serif;
}

.tree-content code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #495057;
}

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

.tree ul {
    padding-right: 30px;
    margin: 5px 0;
}

.tree ul.collapsed {
    display: none;
}

/* Level-based indentation */
.tree-item.level-1 { margin-right: 20px; }
.tree-item.level-2 { margin-right: 40px; }
.tree-item.level-3 { margin-right: 60px; }

/* Children List Styles */
.children-list {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.child-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 5px;
    border: 1px solid #e0e0e0;
}

.child-name {
    font-weight: 600;
}

.child-level {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Modal Children Styles */
.children-list-content {
    max-height: 400px;
    overflow-y: auto;
}

.child-modal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
}

.child-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.child-info strong {
    color: #333;
}

.child-info span:not(.badge) {
    color: #666;
    font-size: 14px;
}

/* Help Text */
.help-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    display: block;
}

/* Button Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Badge Level Colors */
.level-0 { background: #e3f2fd; color: #1976d2; }
.level-1 { background: #f3e5f5; color: #7b1fa2; }
.level-2 { background: #e8f5e8; color: #388e3c; }
.level-3 { background: #fff3e0; color: #f57c00; }

/* Code Styles */
code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #e83e8c;
}

/* Responsive Tree */
@media (max-width: 768px) {
    .tree-node {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .tree-actions {
        align-self: flex-end;
    }
    
    .tree-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Select with Refresh Button */
.select-with-refresh {
    position: relative;
    display: flex;
    align-items: center;
}

.select-with-refresh select {
    flex: 1;
    padding-right: 45px;
}

.btn-refresh-small {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-refresh-small:hover {
    background: #5a6fd8;
    transform: translateY(-50%) rotate(180deg);
}

/* Disabled State */
select:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* Option Styles */
option {
    padding: 10px;
}

option:disabled {
    color: #ccc;
    background-color: #f8f9fa;
}

/* Loading States */
.loading-text {
    color: #6c757d;
    font-style: italic;
}

.error-text {
    color: #dc3545;
    font-style: italic;
}