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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #007DC3 0%, #004A8D 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
    margin: 0;
}

.container {
    width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 20px;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

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

.header-logo {
    width: 124px;
    height: 55px;
    flex-shrink: 0;
}

.header-text {
    text-align: left;
}

header h1 {
    color: #007DC3;
    font-size: 1.5em;
    margin-bottom: 5px;
    font-weight: 700;
}

header p {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 0;
}

.visual-table-toggle {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.visual-table-toggle .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.markdown-input-container {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f8f9fa;
    padding: 16px;
}

.markdown-table-input {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    background: #fff;
    color: #1f2328;
}

.markdown-table-input:focus {
    outline: none;
    border-color: #007DC3;
    box-shadow: 0 0 0 3px rgba(0, 125, 195, 0.15);
}

.markdown-input-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.9em;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.table-wrapper {
    margin-bottom: 30px;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

.table-wrapper.collapsed {
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

.visual-table-controls {
    transition: all 0.3s ease;
}

.visual-table-controls.collapsed {
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0;
}

.clear-control {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.paste-menu-container {
    position: relative;
    display: inline-block;
}

.paste-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #d8dee6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 1200;
    overflow: hidden;
}

.paste-menu.hidden {
    display: none;
}

.paste-menu-item {
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: #fff;
    color: #333;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.paste-menu-item:hover {
    background: #f2f7fc;
}

.heading-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border: 2px solid #007DC3;
    border-radius: 6px;
    background: white;
    transition: all 0.3s ease;
}

.heading-toggle-label:hover {
    background: #f8f9fa;
    border-color: #004A8D;
}

.heading-toggle-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #007DC3;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #007DC3 0%, #004A8D 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 125, 195, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0066a8 0%, #003d7a 100%);
    box-shadow: 0 6px 20px rgba(0, 125, 195, 0.6);
    transform: translateY(-2px);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

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

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.table-editor-container {
    position: relative;
    overflow: visible;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 50px;
    background: #f8f9fa;
}

.table-editor-inner {
    position: relative;
    display: inline-block;
    width: 100%;
}

.table-editor-container {
    position: relative;
}

.table-editor {
    display: inline-block;
    min-width: 80%;
    margin-left: 10%;
    margin-right: 10%;
    margin-top: 2%;
    margin-bottom: 2%;
    position: relative;
}

.table-out-of-date-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(231, 76, 60, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.table-out-of-date-overlay:hover {
    background: rgba(231, 76, 60, 0.98);
    backdrop-filter: blur(10px);
}

.overlay-content {
    text-align: center;
    color: white;
    padding: 30px;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.warning-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.overlay-content h3 {
    font-size: 1.8em;
    margin-bottom: 15px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    font-weight: bold;
}

.overlay-content p {
    font-size: 1.1em;
    margin-bottom: 10px;
    line-height: 1.6;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}

.overlay-hint {
    font-size: 0.95em;
    font-style: italic;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

.btn-directional {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #007DC3;
    background: white;
    color: #007DC3;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
    padding: 0;
    line-height: 1;
}

.btn-directional:hover {
    background: #007DC3;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-directional:active {
    transform: scale(0.95);
}

.btn-directional.btn-danger {
    border-color: #e74c3c;
    color: #e74c3c;
}

.btn-directional.btn-danger:hover {
    background: #e74c3c;
    color: white;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-top {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.btn-top.btn-danger {
    top: 10px;
    left: calc(50% + 50px);
    transform: translateX(-50%);
}

.btn-top:hover,
.btn-top.btn-danger:hover {
    transform: translateX(-50%) scale(1.1);
}

.btn-top:active,
.btn-top.btn-danger:active {
    transform: translateX(-50%) scale(0.95);
}

.btn-bottom {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.btn-bottom.btn-danger {
    bottom: 10px;
    left: calc(50% + 50px);
    transform: translateX(-50%);
}

.btn-bottom:hover,
.btn-bottom.btn-danger:hover {
    transform: translateX(-50%) scale(1.1);
}

.btn-bottom:active,
.btn-bottom.btn-danger:active {
    transform: translateX(-50%) scale(0.95);
}

.btn-left {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.btn-left.btn-danger {
    left: 10px;
    top: calc(50% + 50px);
    transform: translateY(-50%);
}

.btn-left:hover,
.btn-left.btn-danger:hover {
    transform: translateY(-50%) scale(1.1);
}

.btn-left:active,
.btn-left.btn-danger:active {
    transform: translateY(-50%) scale(0.95);
}

.btn-right {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.btn-right.btn-danger {
    right: 10px;
    top: calc(50% + 50px);
    transform: translateY(-50%);
}

.btn-right:hover,
.btn-right.btn-danger:hover {
    transform: translateY(-50%) scale(1.1);
}

.btn-right:active,
.btn-right.btn-danger:active {
    transform: translateY(-50%) scale(0.95);
}

.visual-table {
    border-collapse: collapse;
    width: 100%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.visual-table td,
.visual-table th {
    border: 2px solid #007DC3;
    padding: 12px;
    min-width: 120px;
    min-height: 40px;
    position: relative;
    background: white;
    transition: all 0.2s ease;
    white-space: pre-wrap;
}

.visual-table td:hover {
    background: #f0f4ff;
}

.visual-table td:focus {
    outline: 3px solid #007DC3;
    outline-offset: -3px;
    background: #fff;
    z-index: 10;
}

.visual-table td.selected {
    background: #007DC3;
    color: black;
}

.visual-table td.merged {
    background: #e8f0fe;
}

.visual-table td[colspan] {
    text-align: center;
}

.visual-table td[rowspan] {
    vertical-align: middle;
}

.visual-table thead {
    background: #e8f0fe;
}

.visual-table thead th {
    background: #007DC3 !important;
    color: white !important;
    font-weight: 600 !important;
    border-color: #004A8D !important;
}

.visual-table thead th:hover {
    background: #0066a8 !important;
}

.visual-table thead th:focus {
    outline: 3px solid #004A8D !important;
    outline-offset: -3px;
    background: #0066a8 !important;
}

.visual-table thead th.selected {
    background: #004A8D !important;
    color: white !important;
}

.merge-controls {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.merge-controls h3 {
    margin-bottom: 15px;
    color: #007DC3;
}

.merge-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.hint {
    color: #666;
    font-size: 0.9em;
    font-style: italic;
}

.alignment-controls {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.alignment-controls h3 {
    margin-bottom: 15px;
    color: #007DC3;
}

.alignment-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.alignment-buttons label {
    color: #333;
    font-weight: 500;
}

.alignment-select {
    padding: 8px 12px;
    border: 2px solid #007DC3;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.alignment-select:hover {
    border-color: #004A8D;
    background: #f8f9fa;
}

.alignment-select:focus {
    outline: none;
    border-color: #004A8D;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.outputs-wrapper {
    margin-top: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.output-container {
    display: flex;
    flex-direction: column;
}

.html-preview-container {
    display: flex;
    flex-direction: column;
}

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

.output-header h2 {
    color: #007DC3;
    font-size: 1.8em;
}

.output-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.html-table-preview {
    min-height: 600px;
    padding: 15px;
    border: 2px solid #007DC3;
    border-radius: 8px;
    background: white;
    overflow: auto;
    max-height: 900px;
}

.html-table-preview table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.html-table-preview table th,
.html-table-preview table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.html-table-preview table th {
    background: #007DC3;
    color: white;
    font-weight: 600;
}

/*.html-table-preview table tr:nth-child(even) {
    background: #f8f9fa;
}*/

/*.html-table-preview table tr:hover {
    background: #e8f0fe;
}*/

.preview-placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 40px;
}

.pandoc-output {
    width: 100%;
    height: 600px;
    min-height: 600px;
    min-width: 300px;
    max-height: 80vh;
    border: 2px solid #007DC3;
    border-radius: 8px;
    overflow: hidden;
    resize: both;
    position: relative;
}

.pandoc-output-cm {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.pandoc-output-cm .CodeMirror {
    height: 100% !important;
    width: 100% !important;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 8px;
    flex: 1;
}

.pandoc-output-cm .CodeMirror-focused {
    outline: 3px solid #007DC3;
    outline-offset: -3px;
}

.pandoc-output-cm .CodeMirror-scroll {
    height: 100%;
    overflow-x: auto;
    overflow-y: auto;
    margin-bottom: 5px;
    margin-right: 5px;
}

.pandoc-output-cm .CodeMirror-scrollbar {
    margin-bottom: 5px;
    margin-right: 5px;
}

.pandoc-output-cm .CodeMirror-sizer {
    min-height: 100% !important;
}

/* When line wrapping is off, ensure horizontal overflow */
.pandoc-output-cm .CodeMirror-lines {
    overflow-x: auto;
    padding-bottom: 10px;
    padding-right: 10px;
}

/* Resize handle styling */
.pandoc-output::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 0%, transparent 40%, rgba(102, 126, 234, 0.2) 40%, rgba(102, 126, 234, 0.2) 100%);
    pointer-events: none;
    z-index: 10;
}

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

    header h1 {
        font-size: 1.8em;
    }

    .table-editor-container {
        padding: 40px 20px;
    }

    .btn-directional {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .btn-top.btn-danger {
        left: calc(50% + 45px);
    }

    .btn-bottom.btn-danger {
        left: calc(50% + 45px);
    }

    .btn-left.btn-danger {
        top: calc(50% + 45px);
    }

    .btn-right.btn-danger {
        top: calc(50% + 45px);
    }

    .outputs-wrapper {
        grid-template-columns: 1fr;
    }
    
    .output-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}
