/* Game Server Edit Page Styles */

.edit-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

.back-button:hover {
    color: white;
}

.back-icon {
    font-size: 1.2rem;
}

.header-content {
    margin-bottom: 1.5rem;
}

.header-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.config-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.section-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
}

.section-description {
    color: #666;
    margin: 0;
    font-size: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fafafa;
}

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

.form-group input[readonly] {
    background: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

.form-help {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* Editor Styles */
.template-editor,
.schema-editor,
.script-editor {
    margin-top: 1rem;
}

.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.editor-container {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.editor-container textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    background: #f8f9fa;
}

.editor-container textarea:focus {
    outline: none;
    background: white;
}

.editor-help {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--realmify-deep-grid-gray);
    border: 1px solid var(--realmify-border-dark);
    border-left: 4px solid var(--realmify-voxel-blue);
    border-radius: var(--realmify-radius);
    box-shadow: var(--realmify-shadow-card);
}

.editor-help h4 {
    margin: 0 0 0.5rem 0;
    color: var(--realmify-text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.editor-help ul {
    margin: 0;
    padding-left: 1.5rem;
}

.editor-help li {
    margin-bottom: 0.25rem;
    color: var(--realmify-text-secondary);
    font-size: 0.9rem;
}

.editor-help code {
    background: var(--realmify-dark-bg);
    border: 1px solid var(--realmify-border-dark);
    color: var(--realmify-voxel-blue);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
}

/* Preview Section */
.preview-container {
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.preview-content {
    padding: 2rem;
    min-height: 200px;
}

.preview-content h3 {
    color: #2c3e50;
    margin-top: 0;
}

.preview-content .form-group {
    margin-bottom: 1rem;
}

.preview-content input,
.preview-content select,
.preview-content textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Loading and Error States */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

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

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

.error-message {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #fcc;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #dfd;
    color: #363;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid #cfc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .edit-header {
        padding: 1.5rem;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
    
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .config-section {
        padding: 1.5rem;
    }
    
    .editor-toolbar {
        flex-direction: column;
    }
    
    .editor-container textarea {
        min-height: 200px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .edit-header {
        padding: 1rem;
    }
    
    .config-section {
        padding: 1rem;
    }
    
    .editor-container textarea {
        min-height: 150px;
        padding: 0.75rem;
    }
}

/* Scripts Section Styles */
.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.script-editor {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.script-editor:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.script-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

.script-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
    margin: 0 0 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.script-description {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0;
}

.script-editor .editor-toolbar {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.script-editor .editor-container {
    position: relative;
}

.script-editor .editor-container textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    background: #ffffff;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.script-editor .editor-container textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.scripts-help {
    background: var(--realmify-deep-grid-gray);
    border: 1px solid var(--realmify-border-dark);
    border-left: 4px solid var(--realmify-voxel-blue);
    border-radius: var(--realmify-radius);
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--realmify-shadow-card);
}

.scripts-help h4 {
    color: var(--realmify-voxel-blue);
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.scripts-help ul {
    margin: 0;
    padding-left: 1.5rem;
}

.scripts-help li {
    margin-bottom: 0.5rem;
    color: var(--realmify-text-secondary);
    font-size: 0.9rem;
}

.scripts-help code {
    background: var(--realmify-dark-bg);
    border: 1px solid var(--realmify-border-dark);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: var(--realmify-voxel-blue);
}

/* Responsive Scripts */
@media (max-width: 768px) {
    .scripts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .script-editor {
        padding: 1rem;
    }
    
    .script-editor .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .script-editor .editor-container textarea {
        min-height: 100px;
        font-size: 0.8rem;
    }
}

/* File Templates Styles */
.file-templates-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
}

.file-templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.file-templates-info {
    color: #6c757d;
    font-size: 0.9rem;
}

.file-templates-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-template-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.file-template-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.file-template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.file-template-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.1rem;
}

.file-template-actions {
    display: flex;
    gap: 0.5rem;
}

.file-template-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.file-template-path {
    color: #6c757d;
    font-size: 0.9rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.file-template-description {
    color: #6c757d;
    font-size: 0.9rem;
    font-style: italic;
}

.file-template-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.status-active {
    color: #28a745;
    font-weight: 500;
}

.status-inactive {
    color: #dc3545;
    font-weight: 500;
}

.file-template-script-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: #495057;
    max-height: 100px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* File Template Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #dc3545;
}

.modal-body {
    padding: 1.5rem;
}

.template-editor-container {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
}

.template-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.template-editor-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.template-editor-info {
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
}

.template-editor-container textarea {
    border: none;
    border-radius: 0;
    background: white;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 400px;
    height: 500px;
    width: 100%;
}

.template-editor-container textarea:focus {
    outline: none;
    box-shadow: none;
}

/* Highlight template variables */
.template-editor-container textarea {
    background-image: 
        linear-gradient(90deg, transparent 0%, transparent 100%),
        linear-gradient(90deg, #fff3cd 0%, #fff3cd 100%);
    background-size: 100% 100%, 0% 100%;
    background-repeat: no-repeat;
    background-position: 0 0, 0 0;
}

.template-editor-container textarea:focus {
    background-image: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* Responsive File Templates */
@media (max-width: 768px) {
    .file-templates-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .file-template-info {
        grid-template-columns: 1fr;
    }
    
    .file-template-actions {
        flex-wrap: wrap;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .template-editor-container textarea {
        min-height: 300px;
        height: 350px;
    }
}

@media (min-width: 1200px) {
    .template-editor-container textarea {
        min-height: 500px;
        height: 600px;
    }
}
