/* ===========================
   SQL Query Simulator - Light Theme
   =========================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-blue: #3b82f6;
    
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 25px 30px;
    margin-bottom: 25px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 2rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

header p {
    color: var(--gray-500);
    font-size: 0.95rem;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-back {
    background: var(--white);
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-back:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

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

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

.btn-tutorial {
    background: var(--accent-blue);
    color: var(--white);
}

.btn-demo {
    background: var(--accent-orange);
    color: var(--white);
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 25px;
}

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

/* Section Panels */
.section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

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

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h2 i {
    color: var(--primary);
    font-size: 1rem;
}

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

.table-item {
    padding: 12px 15px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.table-item:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.table-item:hover i {
    color: var(--white);
}

.table-item i {
    color: var(--primary);
}

.table-item.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.table-item.active i {
    color: var(--white);
}

.table-name {
    font-weight: 500;
}

.table-count {
    margin-left: auto;
    font-size: 12px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    color: var(--primary);
}

.table-item:hover .table-count,
.table-item.active .table-count {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

/* Query History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Query Editor */
.query-editor-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

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

.editor-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-header h2 i {
    color: var(--primary);
}

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

.query-editor {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    background: var(--gray-900);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    color: #e0e0e0;
    resize: vertical;
    line-height: 1.6;
}

.query-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.query-editor::placeholder {
    color: var(--gray-500);
}

/* Results Panel */
.results-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

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

.results-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-header h2 i {
    color: var(--accent-green);
}

.result-stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--gray-500);
}

.result-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Results Table */
.results-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.results-table th {
    background: var(--gray-100);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

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

.results-table tr:hover {
    background: var(--gray-50);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--gray-300);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--gray-600);
}

.empty-state p {
    font-size: 0.95rem;
}

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 15px;
    color: var(--accent-red);
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-message i {
    font-size: 1.25rem;
}

/* Success Message */
.success-message {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius);
    padding: 15px;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Sample Queries */
.sample-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.sample-query {
    padding: 8px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fira Code', monospace;
}

.sample-query:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-900);
}

.modal-content h2 i {
    color: var(--primary);
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
}

.close:hover {
    color: var(--gray-600);
}

/* Tutorial Content */
.tutorial-content {
    max-height: 60vh;
    overflow-y: auto;
}

.tutorial-section {
    margin-bottom: 20px;
}

.tutorial-section h3 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 1rem;
}

.tutorial-section p,
.tutorial-section ul {
    color: var(--gray-600);
    font-size: 0.95rem;
    line-height: 1.7;
}

.tutorial-section ul {
    padding-left: 20px;
}

.tutorial-section li {
    margin-bottom: 5px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        gap: 20px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .sidebar .section {
        flex: 1;
        min-width: 250px;
    }
    
    .container {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 20px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .header-buttons {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .sidebar .section {
        min-width: 100%;
    }
    
    .quick-queries {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    .header-buttons .btn span {
        display: none;
    }
    
    .editor-section textarea {
        font-size: 13px;
        min-height: 120px;
    }
    
    .results-table {
        font-size: 12px;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .header-buttons {
        gap: 8px;
    }
    
    .section h3 {
        font-size: 0.9rem;
    }
    
    .quick-query-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Fix query editor buttons collision on mobile */
    .query-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .query-buttons .btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }
    
    .query-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .query-tabs .tab {
        flex: 1;
        min-width: 45%;
        font-size: 11px;
        padding: 8px 6px;
        text-align: center;
    }
    
    .editor-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .editor-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    header {
        padding: 12px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .container {
        padding: 8px;
    }
    
    /* Ensure buttons don't collide on very small screens */
    .query-buttons .btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .query-tabs .tab {
        min-width: 100%;
        font-size: 12px;
        padding: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
    }
    
    .quick-query-btn {
        min-height: 44px;
    }
    
    .results-table th,
    .results-table td {
        padding: 12px;
    }
}
