/* Admin Panel Styles */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-color: #ecf0f1;
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: #333;
    line-height: 1.6;
}

/* Admin Container */
.admin-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.admin-header {
    grid-column: 1 / -1;
    background: white;
    border-bottom: 3px solid var(--primary-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 100;
}

.admin-header h1 {
    font-size: 24px;
    color: var(--secondary-color);
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* Sidebar */
.admin-sidebar {
    background: var(--secondary-color);
    color: white;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    padding: 15px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: var(--primary-color);
}

.nav-item.active {
    background: rgba(52, 152, 219, 0.2);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* Main Content */
.admin-main {
    overflow-y: auto;
    padding: 30px;
    background: var(--bg-color);
}

.admin-section {
    display: none;
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.admin-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.admin-section h2 {
    color: var(--secondary-color);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-color);
    font-size: 22px;
}

.admin-section h3 {
    color: var(--secondary-color);
    margin: 20px 0 15px;
    font-size: 18px;
}

/* Form Elements */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 14px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-control:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}


.coords-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Buttons */
button {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.section-actions {
    margin-bottom: 25px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead {
    background: var(--secondary-color);
    color: white;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.data-table .actions {
    display: flex;
    gap: 8px;
}

.data-table .actions button {
    padding: 6px 12px;
    font-size: 12px;
}

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

/* QR Display */
.qr-display {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

.qr-display canvas {
    border: 3px solid white;
    box-shadow: var(--shadow);
    border-radius: 6px;
}

.qr-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Image Preview */
.image-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.image-preview.empty {
    color: #95a5a6;
    font-style: italic;
}

/* Iframe Preview */
.iframe-preview {
    margin-top: 20px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: white;
}

.iframe-preview.hidden {
    display: none;
}

.preview-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    margin: 0;
    color: white;
    font-size: 16px;
}

.close-preview {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-preview:hover {
    background: rgba(255,255,255,0.3);
}

.iframe-preview iframe {
    width: 100%;
    height: 600px;
    border: none;
    display: block;
}

/* Language Grid */
.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.language-card {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    padding: 20px;
    transition: all 0.3s ease;
}

.language-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.language-card h4 {
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.language-card .audio-info {
    font-size: 13px;
    color: #7f8c8d;
    margin: 10px 0;
}

.audio-details {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    margin: 10px 0;
    font-size: 13px;
}

.audio-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #e0e0e0;
}

.audio-detail-row:last-child {
    border-bottom: none;
}

.audio-detail-row strong {
    color: var(--secondary-color);
    min-width: 60px;
}

.audio-detail-row span {
    color: #555;
    word-break: break-all;
    text-align: right;
    flex: 1;
    margin-left: 10px;
}

.language-card audio {
    width: 100%;
    margin-top: 10px;
}

/* Upload Progress */
.upload-progress {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.upload-progress.hidden {
    display: none;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #2980b9);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: bold;
}

.progress-text {
    text-align: center;
    font-size: 13px;
    color: var(--secondary-color);
    font-weight: 500;
}

.language-card .card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.language-card .card-actions button {
    flex: 1;
    padding: 8px;
    font-size: 12px;
}

/* Audio Preview */
.audio-preview {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

.audio-preview audio {
    width: 100%;
}

/* Labels Table */
.labels-table {
    width: 100%;
    border-collapse: collapse;
}

.labels-table th,
.labels-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.labels-table th {
    background: var(--secondary-color);
    color: white;
    font-weight: 600;
}

.labels-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.labels-table input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Map Configuration */
.map-config {
    margin-top: 20px;
}

.map-config.hidden {
    display: none;
}

/* Map Editor */
.map-editor {
    margin-top: 30px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 20px;
    background: white;
}

.map-editor.hidden {
    display: none;
}

.map-canvas-container {
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    overflow: auto;
    max-height: 600px;
    background: #f8f9fa;
    margin-bottom: 20px;
}

.map-canvas-container canvas {
    display: block;
    cursor: crosshair;
}

.map-points-list {
    margin-top: 20px;
}

.map-points-list ul {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    padding: 10px;
}

.map-points-list li {
    padding: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-points-list li:last-child {
    border-bottom: none;
}

/* Test Grid */
.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.test-card {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    padding: 25px;
    text-align: center;
}

.test-card h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.test-card p {
    color: #7f8c8d;
    margin-bottom: 20px;
    font-size: 14px;
}

.test-card input {
    margin-bottom: 15px;
}

.test-card canvas {
    margin-top: 15px;
    border: 2px solid white;
    box-shadow: var(--shadow);
    border-radius: 6px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

.modal-content.large {
    max-width: 900px;
}

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

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid var(--bg-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    border: none;
    padding: 0;
}

.close-modal {
    background: transparent;
    color: #95a5a6;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.close-modal:hover {
    background: var(--bg-color);
    color: var(--secondary-color);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 2px solid var(--bg-color);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #ddd;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 16px;
    color: var(--secondary-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: var(--border-radius);
    padding: 15px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
    border-left: 4px solid;
}

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

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 24px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

.toast-close {
    background: transparent;
    border: none;
    color: #95a5a6;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .admin-container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) auto 1fr;
    }
    
    .admin-sidebar {
        grid-row: 2;
        grid-column: 1;
        overflow-x: auto;
    }
    
    .nav-menu {
        display: flex;
        gap: 10px;
        padding: 0 20px;
    }
    
    .nav-item {
        white-space: nowrap;
        padding: 10px 20px;
    }
}

@media (max-width: 768px) {
    .admin-main {
        padding: 15px;
    }
    
    .admin-section {
        padding: 20px;
    }
    
    .header-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .header-actions button {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .coords-group {
        grid-template-columns: 1fr;
    }
    
    .test-grid {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .admin-sidebar,
    .header-actions,
    button {
        display: none !important;
    }
    
    .admin-main {
        padding: 0;
    }
    
    .admin-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
