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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

header {
    flex-shrink: 0;
    padding: 0.75rem 0;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 600;
}

#calculateBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.main-content {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.main-content .row {
    margin: 0;
    height: 100%;
}

.editor-panel,
.output-panel {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid #dee2e6;
}

.output-panel {
    border-right: none;
    border-left: 1px solid #dee2e6;
}

.panel-header {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #dee2e6;
    flex-shrink: 0;
}

.panel-header h6 {
    color: #495057;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-header-content {
    flex: 1;
    text-align: left;
}

.output-header-content {
    flex: 1;
    text-align: right;
}

.calculating-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    color: #0d6efd;
    animation: spin 1s linear infinite;
}

.calculating-indicator.hidden {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.editor-textarea {
    flex: 1;
    border: none;
    border-radius: 0;
    resize: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 17px;
    padding: 1rem;
    line-height: 1.6;
}

.editor-textarea:focus {
    box-shadow: none;
    outline: none;
}

.output-content {
    /* font-family: Georgia, 'Times New Roman', Times, serif; */
    font-family: Verdana, sans-serif;
    padding: 1rem;
    height: calc(100vh - 100px);
    overflow-y: auto;
    background-color: #fff;
    border-radius: 0 0 0.25rem 0.25rem;
    line-height: 1.0;
}

.output-content h1,
.output-content h2,
.output-content h3,
.output-content h4,
.output-content h5,
.output-content h6 {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    color: #212529;
}

.output-content h1 {
    font-size: 2rem;
    margin-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.output-content h2 {
    font-size: 1.5rem;
    margin-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.output-content h3 {
    font-size: 1rem;
    margin-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.output-content p {
    margin-bottom: 1rem;
    /* line-height: 1.6; */
}

.output-content code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    color: #d63384;
}

.output-content pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
}

.output-content pre code {
    background-color: transparent;
    padding: 0;
    color: #212529;
}

.calculation-line {
    padding: 0.25rem 0;
    margin: 0.25rem 0;
    /* font-family: 'Courier New', Courier, monospace; */
    color: #212529;
}

.calculation-result {
    padding: 0.25rem 0;
    margin: 0.25rem 0;
    /* font-family: 'Courier New', Courier, monospace; */
    color: #212529;
}

.calculation-result strong {
    font-weight: normal;
    color: #0d6efd;
}

.calculation-description {
    color: #6c757d;
    font-style: italic;
    margin-right: 0.5rem;
}

.error-message {
    background-color: #f8d7da;
    color: #842029;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
}

/* Scrollbar styling */
.output-content::-webkit-scrollbar,
.editor-textarea::-webkit-scrollbar {
    width: 8px;
}

.output-content::-webkit-scrollbar-track,
.editor-textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.output-content::-webkit-scrollbar-thumb,
.editor-textarea::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.output-content::-webkit-scrollbar-thumb:hover,
.editor-textarea::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Prevent iOS zoom on input focus */
@supports (-webkit-touch-callout: none) {
    /* iOS specific styles */
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    html, body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    .main-content .row {
        flex-direction: column;
    }

    .editor-panel,
    .output-panel {
        height: 100%;
        border-right: none;
        border-left: none;
        border-bottom: none;
        position: absolute;
        top: 56px; /* Height of navbar */
        left: 0;
        right: 0;
        bottom: 0;
        transition: transform 0.3s ease;
        overflow: hidden;
    }

    .editor-panel {
        transform: translateX(0);
        z-index: 2;
    }

    .editor-panel.hidden {
        transform: translateX(-100%);
    }

    .output-panel {
        transform: translateX(100%);
        z-index: 1;
    }

    .output-panel.visible {
        transform: translateX(0);
        z-index: 2;
    }

    .mobile-view-toggle {
        display: inline-block;
        cursor: pointer;
        padding: 0.25rem 0.5rem;
        border-radius: 0.25rem;
        transition: background-color 0.2s;
    }

    .mobile-view-toggle:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }

    .mobile-view-toggle.hidden {
        display: none;
    }

    /* Ensure textarea and output content don't cause page scroll */
    .editor-textarea,
    .output-content {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
}

@media (min-width: 769px) {
    .mobile-view-toggle {
        display: none;
    }
    
    .output-header-content {
        text-align: left;
    }
}

.dropdown-menu .btn-outline-secondary {
    border: none;
    background: none;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
}

.dropdown-menu .btn-outline-secondary:hover {
    background: none;
    color: #495057;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

.dropdown-menu .btn-outline-secondary.active {
    background: none;
    border: none;
    color: #0d6efd;
}

.dropdown-menu .btn-outline-secondary:focus {
    box-shadow: none;
}

/* Remove spinners from font size input */
.dropdown-menu #fontSizeInput::-webkit-inner-spin-button,
.dropdown-menu #fontSizeInput::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dropdown-menu #fontSizeInput {
    -moz-appearance: textfield;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #dee2e6;
    background: #fff;
    width: 60px;
}

/* Style the +/- buttons */
.dropdown-menu #decreaseFontSize,
.dropdown-menu #increaseFontSize {
    border: 1px solid #dee2e6;
    padding: 0.25rem 0.5rem;
    min-width: 32px;
}

/* Adjust gap between buttons and input */
.dropdown-menu .d-flex.gap-2 {
    gap: 0.25rem !important;
}

/* Dark theme styles for font size controls */
[data-bs-theme="dark"] .dropdown-menu #fontSizeInput {
    background: #2b3035;
    border-color: #495057;
    color: #fff;
}

[data-bs-theme="dark"] .dropdown-menu #decreaseFontSize,
[data-bs-theme="dark"] .dropdown-menu #increaseFontSize {
    border-color: #495057;
}

/* Dark theme styles */
[data-bs-theme="dark"] {
    background-color: #212529;
    color: #dee2e6;
}

[data-bs-theme="dark"] .editor-textarea {
    background-color: #2b3035;
    color: #dee2e6;
    border-color: #495057;
}

[data-bs-theme="dark"] .output-content {
    background-color: #2b3035;
    color: #dee2e6;
}

[data-bs-theme="dark"] .panel-header {
    background-color: #343a40;
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .output-panel {
    border-right-color: #495057;
}

[data-bs-theme="dark"] .calculation-result {
    background-color: #1a1d20;
    border-left-color: #0d6efd;
}

[data-bs-theme="dark"] .output-content code {
    background-color: #1a1d20;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .output-content pre {
    background-color: #1a1d20;
    border-color: #495057;
}