/**
 * Obliczanki.pl - Main Application Styles
 *
 * Split-panel interface, form styling, and responsive layout
 *
 * @version 0.1.0
 * @author Michał Głębowski
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f0f0f0;
}

/* NoScript Warning */
.noscript-warning {
    background: #ff9800;
    color: #000;
    padding: 30px 20px;
    text-align: center;
    border-bottom: 4px solid #f57c00;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.noscript-warning h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #000;
}

.noscript-warning p {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 10px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.noscript-warning strong {
    font-weight: bold;
    color: #1a1a1a;
}

/* Container - Split-Panel Layout */
.container {
    display: flex;
    height: 100vh;
    gap: 0;
    overflow: hidden;
}

/* Panels */
.panel {
    overflow-y: auto;
}

.panel-left {
    flex: 0 0 420px;
    background: #ffffff;
    border-right: 2px solid #ccc;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.panel-right {
    flex: 1;
    background: #e8e8e8;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Header - Sticky at top */
.panel-header {
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.header-content {
    text-align: center;
}

.panel-header h1 {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 5px;
}

.panel-header .subtitle {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 0;
}

.actions-top {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    justify-content: center;
}

/* Form Styling */
form {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

fieldset {
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    background: #fafafa;
}

legend {
    font-weight: bold;
    color: #2c3e50;
    padding: 0 10px;
    font-size: 15px;
}

label {
    display: block;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

label input[type="checkbox"],
label input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

input[type="number"],
select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
    font-family: inherit;
    width: auto;
    min-width: 80px;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 3px rgba(52, 152, 219, 0.3);
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.form-row label {
    flex: 1;
}

/* Buttons */
.actions {
    margin-top: 20px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #27ae60;
    color: white;
}

.btn-secondary:hover {
    background: #229954;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: #27ae60; /* Don't change on hover when disabled */
}

/* Footer */
.panel-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 12px;
    color: #7f8c8d;
}

/* Preview Panel */
.panel-right h2 {
    font-size: 22px;
    color: #2c3e50;
    margin-bottom: 15px;
}

#previewArea {
    flex: 1;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 20px;
    overflow: auto;
    position: relative;
}

.placeholder {
    text-align: center;
    color: #95a5a6;
    padding: 100px 20px;
    font-size: 16px;
}

.loading {
    text-align: center;
    color: #3498db;
    padding: 100px 20px;
    font-size: 16px;
    font-style: italic;
}

.error {
    text-align: center;
    color: #e74c3c;
    padding: 50px 20px;
    font-size: 14px;
}

/* Worksheet Preview (Scaled Down) */
.worksheet-preview {
    transform: scale(0.65);
    transform-origin: top left;
    width: 153.85%; /* Compensate for 0.65 scale (100 / 0.65) */
}

/* Worksheet Table Styles */
.worksheet {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    background: white;
    margin-bottom: 40px;
}

.worksheet:last-child {
    margin-bottom: 0;
}

.worksheet th,
.worksheet td {
    border: 1px solid #333;
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.worksheet thead th {
    background: #f5f5f5;
    font-weight: bold;
    text-align: center;
    font-size: 14px;
}

.worksheet.no-grid th,
.worksheet.no-grid td {
    border: none;
}

/* Exercise Cell */
.exercise {
    min-height: 50px;
}

.exercise .number {
    font-weight: bold;
    margin-right: 8px;
    color: #555;
}

.exercise .expression {
    font-size: 15px;
    font-family: 'Courier New', monospace;
}

/* Solution Sheet */
.worksheet.solutions thead th {
    background: #e8f5e9;
}

.worksheet.solutions .answer {
    font-weight: bold;
    color: #27ae60;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .panel-left {
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 2px solid #ccc;
        max-height: 50vh;
    }

    .panel-right {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .panel-left {
        padding: 15px;
    }

    .panel-right {
        padding: 15px;
    }

    header h1 {
        font-size: 24px;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .actions-top {
        flex-direction: column;
    }

    .actions-top .btn {
        width: 100%;
    }
}

/* Symbol Font Support */
.operator {
    font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial, sans-serif;
}
