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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    color: #e0e0e0;
    min-height: 100vh;
    line-height: 1.4;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

.container {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

header h1 {
    font-size: 2em;
    margin-bottom: 5px;
    background: linear-gradient(45deg, #64b5f6, #42a5f5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 1em;
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

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

.task-header h2 {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

.task-header .controls {
    margin-bottom: 0;
    justify-content: flex-end;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, #4caf50, #45a049);
    color: white;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-primary {
    background: linear-gradient(45deg, #2196f3, #1976d2);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #ff9800, #f57c00);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.btn-tertiary {
    background: linear-gradient(45deg, #9c27b0, #7b1fa2);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

.btn-tertiary:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.btn-execute {
    width: 100%;
    margin-top: 10px;
    background: linear-gradient(45deg, #4caf50, #45a049);
    font-size: 1em;
    padding: 10px;
}

main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 60vh auto;
    gap: 15px;
}

.database-section {
    grid-column: 1;
    grid-row: 1;
    overflow-y: auto;
    min-height: 400px;
}

.task-section {
    grid-column: 2;
    grid-row: 1;
    overflow-y: auto;
}

.query-section {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.database-section,
.task-section,
.query-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

h2 {
    margin-bottom: 15px;
    color: #64b5f6;
    font-size: 1.2em;
    border-bottom: 2px solid rgba(100, 181, 246, 0.3);
    padding-bottom: 8px;
    flex-shrink: 0;
}

h3 {
    margin-bottom: 10px;
    color: #81c784;
    font-size: 1.1em;
    flex-shrink: 0;
}

#tablesContainer {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.table-container {
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.table-title {
    background: linear-gradient(45deg, #37474f, #455a64);
    padding: 8px 12px;
    font-weight: bold;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9em;
}

.table-title.clickable {
    cursor: pointer;
    transition: background 0.3s ease;
}

.table-title.clickable:hover {
    background: linear-gradient(45deg, #455a64, #546e7a);
}

.table-schema {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin: 8px;
    padding: 8px;
}

.schema-title, .data-title {
    font-size: 0.85em;
    font-weight: 600;
    color: #81c784;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(129, 199, 132, 0.3);
}

.schema-table, .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
}

.schema-table th, .schema-table td {
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.schema-table th {
    background: rgba(129, 199, 132, 0.2);
    color: #81c784;
    font-weight: 600;
    font-size: 0.75em;
}

.column-name {
    font-weight: 600;
    color: #64b5f6;
}

.column-type {
    color: #ffb74d;
    font-style: italic;
}

.table-data {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin: 8px;
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

th, td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    background: rgba(100, 181, 246, 0.2);
    color: #64b5f6;
    font-weight: 600;
}

tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.task-description {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    padding: 15px;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.solution-container {
    background: rgba(156, 39, 176, 0.1);
    border: 1px solid rgba(156, 39, 176, 0.3);
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px;
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}

#solutionCode {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 12px;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    margin: 0;
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#sqlQuery {
    width: 100%;
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    resize: vertical;
    transition: border-color 0.3s ease;
    flex-shrink: 0;
}

#sqlQuery:focus {
    outline: none;
    border-color: #64b5f6;
    box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.2);
}

.result-container {
    display: flex;
    flex-direction: column;
    margin-top: 15px;
    min-height: 0;
}

#queryResult {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
    min-height: 100px;
}

.success {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
    color: #81c784;
    font-size: 0.95em;
    font-weight: 500;
}

.error {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    color: #ef5350;
    font-size: 0.95em;
    font-weight: 500;
}

.result-table {
    width: 100%;
    margin-top: 10px;
    font-size: 0.85em;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    overflow: hidden;
}

.result-table th {
    background: rgba(76, 175, 80, 0.3);
    color: #81c784;
    padding: 8px 12px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.result-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
}

.result-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.result-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.task-section {
    display: flex;
    flex-direction: column;
    max-height: none;
}

/* Responsywność dla małych ekranów */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }

    .database-section {
        grid-column: 1;
        grid-row: 1;
        max-height: 500px;
    }

    .task-section {
        grid-column: 1;
        grid-row: 2;
        max-height: 200px;
        overflow-y: auto;
    }

    .query-section {
        grid-column: 1;
        grid-row: 3;
        height: 1500px;
    }

    .result-container {
        min-height: 250px;
    }

    #queryResult {
        font-size: 0.9em;
    }

    .result-table {
        font-size: 0.9em;
    }

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

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.6em;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 250px;
        padding: 10px;
    }

    .content-grid {
        gap: 10px;
        grid-template-rows: auto auto 1fr;
    }

    .database-section {
        max-height: 400px;
    }

    .task-section {
        max-height: 150px;
    }

    .query-section {
        height: 1500px;
    }

    .result-container {
        min-height: 200px;
    }

    #sqlQuery {
        height: 50px;
        font-size: 0.9em;
    }

    #queryResult {
        font-size: 1em;
        padding: 12px;
    }

    .result-table {
        font-size: 0.95em;
    }

    .result-table th,
    .result-table td {
        padding: 8px 6px;
        font-size: 0.9em;
    }

    .success,
    .error {
        font-size: 1em;
        padding: 12px;
    }
}

@media (max-height: 700px) {
    header {
        padding: 8px;
        margin-bottom: 8px;
    }

    header h1 {
        font-size: 1.4em;
        margin-bottom: 2px;
    }

    header p {
        font-size: 0.85em;
    }

    .controls {
        margin-bottom: 8px;
    }

    .content-grid {
        grid-template-rows: auto auto 1fr;
    }

    .database-section {
        max-height: 150px;
    }

    .task-section {
        max-height: 120px;
    }

    .query-section {
        height: 1500px;
    }

    .result-container {
        min-height: 150px;
    }

    #sqlQuery {
        height: 40px;
    }

    #queryResult {
        font-size: 0.95em;
    }

    .solution-container {
        max-height: 100px;
    }
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    margin: 2% auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    width: 95%;
    height: 95%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    color: #64b5f6;
    font-size: 1.3em;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover,
.close:focus {
    color: #fff;
    text-decoration: none;
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.modal-table th {
    background: rgba(100, 181, 246, 0.3);
    color: #64b5f6;
    padding: 12px 15px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    vertical-align: top;
}

.modal-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.modal-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        height: 98%;
        margin: 1% auto;
    }
    
    .modal-table {
        font-size: 0.9em;
    }
    
    .modal-table th,
    .modal-table td {
        padding: 8px 10px;
    }
}
