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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    padding: 20px;
    color: #e0e0e0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #1e1e1e;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Navigation Tabs */
.tabs {
    display: flex;
    background: #2d2d2d;
    border-bottom: 2px solid #4d4d4d;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #b0b0b0;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
}

.tab-btn:hover {
    color: #667eea;
    background: #3d3d3d;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #1e1e1e;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tab-content h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.8em;
}

/* Sections */
.section {
    margin-bottom: 30px;
    padding: 20px;
    background: #2d2d2d;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
}

.section h3 {
    color: #e0e0e0;
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* Editor header with fullscreen button */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.editor-header h3 {
    margin: 0;
}

.editor-header .btn {
    margin: 0;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #e0e0e0;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group textarea {
    padding: 12px;
    border: 1px solid #4d4d4d;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s ease;
    background: #2d2d2d;
    color: #e0e0e0;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="text"]:focus,
.form-group input[type="file"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

textarea {
    resize: vertical;
    min-height: 200px;
    font-family: 'Courier New', monospace;
}

small {
    color: #b0b0b0;
    font-size: 0.9em;
    margin-top: 5px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    text-align: center;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-info {
    background: #17a2b8;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.btn-info:hover {
    background: #138496;
}

.btn-success {
    background: #28a745;
    color: white;
    text-decoration: none;
    display: inline-block;
}

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

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

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

.btn-warning {
    background: #ffc107;
    color: #333;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9em;
}

/* Tables */
.file-table {
    width: 100%;
    border-collapse: collapse;
    background: #1e1e1e;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.file-table thead {
    background: #667eea;
    color: white;
}

.file-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.file-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #4d4d4d;
    color: #e0e0e0;
}

.file-table tbody tr:hover {
    background: #333333;
}

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

.file-row td {
    vertical-align: middle;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 6px;
    margin: 15px 0;
    font-weight: 500;
}

.alert-success {
    background: #1e5631;
    color: #a6e3a1;
    border: 1px solid rgba(166, 227, 161, 0.2);
}

.alert-error {
    background: #5f2c2c;
    color: #ff8c8c;
    border: 1px solid rgba(255, 140, 140, 0.2);
}

.alert-info {
    background: #1f4d56;
    color: #7dd3e0;
    border: 1px solid rgba(125, 211, 224, 0.2);
}

.alert-warning {
    background: #664c00;
    color: #ffd699;
    border: 1px solid rgba(255, 214, 153, 0.2);
}

/* Editor Toolbar */
.editor-toolbar-wrapper {
    margin-bottom: 15px;
}

.toolbar-toggle {
    display: block;
    width: 100%;
    background: #2d2d2d;
    color: #667eea;
    border: 1px solid #4d4d4d;
    padding: 10px 15px;
    margin-bottom: 0;
    text-align: left;
    font-weight: 600;
    transition: all 0.3s ease;
}

.toolbar-toggle:hover {
    background: #333333;
    border-color: #667eea;
}

.toolbar-toggle.collapsed {
    margin-bottom: 0;
}

.editor-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    background: #2d2d2d;
    border: 1px solid #4d4d4d;
    border-top: none;
    flex-wrap: wrap;
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
    transition: all 0.3s ease;
}

.editor-toolbar.collapsed {
    display: none;
}

/* Editor Form */
#editorForm {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #4d4d4d;
}

#editorForm .form-group:last-child {
    margin-bottom: 0;
}

/* Upload Form */
#uploadForm .form-group {
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

#uploadForm input[type="file"] {
    flex: 1;
}

#uploadForm .btn {
    margin: 0;
}

/* Search and Process Results */
#searchResult,
#processingResult,
#editorMessage,
#uploadMessage {
    margin-top: 15px;
}

/* Fullscreen Editor */
.section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 20px;
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
}

.section.fullscreen .editor-header {
    position: sticky;
    top: 0;
    background: #2d2d2d;
    padding: 15px 20px;
    margin: -20px -20px 15px -20px;
    border-radius: 0;
    z-index: 10000;
}

.section.fullscreen #editorForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: transparent;
    border: none;
    padding: 0;
}

.section.fullscreen textarea {
    flex: 1;
    min-height: unset;
    height: 100%;
    max-height: none;
    padding: 15px;
    border: 1px solid #4d4d4d;
    border-radius: 6px;
    resize: none;
    background: #1e1e1e;
    color: #e0e0e0;
}

.section.fullscreen .editor-toolbar {
    position: sticky;
    top: 60px;
    background: #2d2d2d;
    padding: 10px 0;
    margin-bottom: 10px;
    z-index: 9999;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        border-radius: 8px;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .tab-content {
        padding: 25px;
    }

    .section {
        padding: 18px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 25px 15px;
    }

    header h1 {
        font-size: 1.6em;
    }

    header p {
        font-size: 1em;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-bottom: none;
        border-left: 3px solid transparent;
        padding: 12px 15px;
    }

    .tab-btn.active {
        border-left-color: #667eea;
        border-bottom: none;
    }

    .tab-content {
        padding: 20px;
    }

    .section {
        padding: 15px;
        margin-bottom: 20px;
    }

    .section h3 {
        font-size: 1.1em;
    }

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

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

    .file-table th {
        font-size: 0.9em;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.95em;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.85em;
        margin: 2px;
    }

    #uploadForm .form-group {
        flex-direction: column;
    }

    #uploadForm input[type="file"] {
        margin-bottom: 10px;
    }

    .editor-toolbar {
        gap: 8px;
        flex-wrap: wrap;
    }

    .editor-toolbar .btn {
        font-size: 0.85em;
        padding: 8px 10px;
        flex: 0 1 auto;
    }

    .toolbar-toggle {
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .editor-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .editor-header h3 {
        word-break: break-word;
    }

    textarea {
        min-height: 150px;
    }
}

@media (max-width: 480px) {
    .container {
        border-radius: 0;
        box-shadow: none;
        margin: 0;
    }

    body {
        padding: 0;
    }

    header {
        padding: 20px 15px;
        border-radius: 0;
    }

    header h1 {
        font-size: 1.3em;
        margin-bottom: 8px;
    }

    header p {
        font-size: 0.9em;
        margin: 0;
    }

    .tabs {
        flex-direction: column;
        border-bottom: none;
    }

    .tab-btn {
        border: none;
        border-bottom: 2px solid #4d4d4d;
        border-left: none;
        padding: 12px;
        font-size: 0.95em;
        text-align: left;
    }

    .tab-btn:last-child {
        border-bottom: none;
    }

    .tab-btn.active {
        border-bottom-color: #667eea;
        border-left: none;
        background: #333333;
    }

    .tab-content {
        padding: 15px;
    }

    .section {
        padding: 12px;
        margin-bottom: 15px;
        border-radius: 6px;
    }

    .section h3 {
        font-size: 1em;
        margin-bottom: 12px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 0.95em;
        margin-bottom: 6px;
    }

    .form-group input[type="text"],
    .form-group input[type="file"],
    .form-group textarea {
        padding: 10px;
        font-size: 16px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 0.9em;
        width: 100%;
        margin-bottom: 8px;
        display: block;
    }

    .btn-sm {
        padding: 6px 8px;
        font-size: 0.8em;
        width: auto;
        display: inline-block;
        margin: 2px 2px 2px 0;
    }

    .file-table {
        font-size: 0.8em;
        display: block;
        overflow-x: auto;
    }

    .file-table thead {
        display: none;
    }

    .file-table tbody,
    .file-table tr,
    .file-table td {
        display: block;
        width: 100%;
    }

    .file-table tr {
        margin-bottom: 15px;
        border: 1px solid #4d4d4d;
        padding: 0;
        border-radius: 6px;
        overflow: hidden;
    }

    .file-table td {
        text-align: right;
        padding: 10px;
        position: relative;
        padding-left: 40%;
        border: none;
        border-bottom: 1px solid #4d4d4d;
    }

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

    .file-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: 600;
        text-align: left;
        color: #667eea;
    }

    #uploadForm .form-group {
        flex-direction: column;
        gap: 10px;
    }

    #uploadForm input[type="file"] {
        margin-bottom: 0;
    }

    #uploadForm .btn {
        width: 100%;
    }

    .editor-toolbar {
        gap: 5px;
        flex-wrap: wrap;
        padding: 8px 12px;
    }

    .editor-toolbar .btn {
        font-size: 0.8em;
        padding: 7px 8px;
        flex: 0 1 48%;
    }

    .toolbar-toggle {
        padding: 10px 12px;
        font-size: 0.9em;
        margin-bottom: 5px;
    }

    .editor-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .editor-header h3 {
        font-size: 1em;
        word-break: break-word;
        margin: 0;
    }

    .editor-header .btn {
        width: 100%;
        margin: 0;
    }

    textarea {
        min-height: 120px;
        font-size: 16px;
    }

    #fileContent {
        min-height: 200px;
    }

    .alert {
        padding: 12px 15px;
        font-size: 0.9em;
        margin: 10px 0;
    }

    /* Fullscreen on mobile */
    .section.fullscreen {
        padding: 10px;
    }

    .section.fullscreen .editor-header {
        margin-bottom: 10px;
    }

    .section.fullscreen textarea {
        border-radius: 4px;
    }
}

@media (max-width: 360px) {
    header h1 {
        font-size: 1.1em;
    }

    header p {
        font-size: 0.8em;
    }

    .tab-btn {
        padding: 10px;
        font-size: 0.9em;
    }

    .btn {
        font-size: 0.85em;
        padding: 8px 10px;
    }

    .section {
        padding: 10px;
        margin-bottom: 12px;
    }

    .file-table td {
        padding: 8px;
        padding-left: 35%;
    }

    .editor-toolbar .btn {
        font-size: 0.75em;
        padding: 6px 6px;
        flex: 0 1 47%;
    }
}
