/* ============================================
   SQL Playground Styles
   ============================================ */

/* Playground Header */
.playground-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 30px 0;
    text-align: center;
}

.playground-header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.playground-header p {
    opacity: 0.9;
}

/* Main Layout */
.playground-main {
    padding: 30px 0;
    min-height: calc(100vh - 300px);
}

.playground-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 25px;
}

/* Sidebar */
.playground-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.sidebar-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* Tables List */
.tables-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.table-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.table-item:hover {
    background: #e2e8f0;
}

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

.table-name {
    flex: 1;
    font-family: var(--font-code);
    font-size: 0.9rem;
    color: var(--primary-color);
}

.view-schema-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font-arabic);
    transition: background 0.2s;
}

.view-schema-btn:hover {
    background: var(--primary-dark);
}

/* Examples List */
.examples-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.example-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-arabic);
    font-size: 0.9rem;
    text-align: right;
    transition: all 0.2s;
}

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

/* Shortcuts */
.shortcuts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

kbd {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-code);
    font-size: 0.8rem;
}

/* Editor Area */
.playground-editor-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.editor-header,
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.editor-header h3,
.results-header h3 {
    font-size: 1rem;
    margin: 0;
}

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

.btn-icon {
    background: none;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--border-color);
}

/* SQL Editor */
.editor-wrapper {
    padding: 0;
}

#sql-editor {
    width: 100%;
    min-height: 200px;
    padding: 20px;
    border: none;
    resize: vertical;
    font-family: var(--font-code);
    font-size: 0.95rem;
    line-height: 1.6;
    direction: ltr;
    text-align: left;
    background: var(--code-bg);
    color: #e2e8f0;
}

#sql-editor:focus {
    outline: none;
}

#sql-editor::placeholder {
    color: #64748b;
}

.editor-footer {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
}

.run-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-icon {
    font-size: 0.8rem;
}

.execution-time {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Results Container */
.results-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.results-info {
    font-size: 0.9rem;
    color: var(--text-light);
}

.results-wrapper {
    max-height: 400px;
    overflow: auto;
}

.results-placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-light);
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    direction: ltr;
    text-align: left;
}

.results-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    font-weight: 600;
    text-align: left;
    position: sticky;
    top: 0;
}

.results-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.results-table tr:nth-child(even) {
    background: var(--bg-color);
}

.results-table tr:hover {
    background: #e2e8f0;
}

/* Error Message */
.error-message {
    background: #fef2f2;
    border-right: 4px solid #ef4444;
    padding: 20px;
    color: #dc2626;
    direction: ltr;
    text-align: left;
    font-family: var(--font-code);
    font-size: 0.9rem;
}

/* Success Message */
.success-message {
    background: #f0fdf4;
    border-right: 4px solid var(--success-color);
    padding: 20px;
    color: #166534;
    text-align: center;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow: auto;
    max-height: calc(80vh - 80px);
}

/* Schema Table */
.schema-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 20px;
    direction: ltr;
    text-align: left;
}

.schema-table th {
    background: var(--bg-color);
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.schema-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.schema-table code {
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.85rem;
}

.sample-data-title {
    margin: 20px 0 10px;
    font-size: 1rem;
    color: var(--text-color);
}

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

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 900px) {
    .playground-layout {
        grid-template-columns: 1fr;
    }

    .playground-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        order: 2;
    }

    .playground-editor-area {
        order: 1;
    }

    .sidebar-section {
        flex: 1;
        min-width: 200px;
    }

    .sidebar-section.ad-container {
        display: none;
    }

    #sql-editor {
        min-height: 150px;
    }
}

@media (max-width: 768px) {
    .playground-header {
        padding: 20px 0;
    }

    .playground-header h1 {
        font-size: 1.5rem;
    }

    .playground-main {
        padding: 20px 0;
    }

    .sidebar-section {
        padding: 15px;
    }

    .sidebar-section h3 {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }

    .table-item {
        padding: 8px;
    }

    .table-name {
        font-size: 0.85rem;
    }

    .example-btn {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .editor-header,
    .results-header {
        padding: 12px 15px;
    }

    .editor-header h3,
    .results-header h3 {
        font-size: 0.95rem;
    }

    #sql-editor {
        padding: 15px;
        font-size: 0.85rem;
        min-height: 120px;
    }

    .results-table {
        font-size: 0.8rem;
    }

    .results-table th,
    .results-table td {
        padding: 8px 10px;
    }

    .results-wrapper {
        max-height: 300px;
    }

    /* Modal Mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-body {
        padding: 15px;
    }

    .schema-table {
        font-size: 0.8rem;
    }

    .schema-table th,
    .schema-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 600px) {
    .sidebar-section {
        min-width: 100%;
    }

    .examples-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .example-btn {
        text-align: center;
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .editor-footer {
        flex-direction: column;
        gap: 10px;
        padding: 12px 15px;
    }

    .run-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .shortcuts {
        display: none;
    }

    .tables-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .table-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }

    .view-schema-btn {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .examples-list,
    .tables-list {
        grid-template-columns: 1fr;
    }

    .table-item {
        flex-direction: row;
    }

    #sql-editor {
        font-size: 0.8rem;
    }
}
