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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background-color: #007bff;
    color: #fff;
    padding: 15px 20px;
    text-align: center;
}

h1 {
    font-size: 24px;
    margin: 0;
}

/* Tab styles */
.tab-container {
    padding: 20px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 20px;
    background-color: #f1f1f1;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.tab-button:hover {
    background-color: #ddd;
}

.tab-button.active {
    background-color: #007bff;
    color: white;
}

.tab-content {
    display: none;
    padding: 10px 0;
}

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

/* Form elements */
label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.sub-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

input[type="text"], 
select, 
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin-bottom: 15px;
}

.input-large {
    font-size: 18px;
    padding: 12px;
}

.button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.button:hover {
    background-color: #0056b3;
}

.checkbox-group, 
.radio-group {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.checkbox-group label,
.radio-group label {
    display: inline;
    margin-left: 5px;
    margin-bottom: 0;
}

/* Regex tab specific styles */
.regex-container {
    display: flex;
    flex-direction: column;
}

.query-input-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.anchor-checkbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
}

.anchor-checkbox label {
    font-size: 20px;
    font-weight: bold;
}

.results-header {
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 16px;
}

.results-list-container {
    margin-bottom: 15px;
}

.results-list {
    width: 100%;
    height: 400px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    font-size: 14px;
    overflow-y: auto;
    background-color: #fff;
}

.result-item {
    padding: 5px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: all 0.2s;
    user-select: none;
    line-height: 1.2;
    position: relative;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background-color: #f0f0f0;
}

.result-item.selected {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

.result-item.selected::after {
    content: "✓";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.sort-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.sort-section label {
    margin-right: 15px;
}

.sort-section .radio-group {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.sort-section .radio-group input {
    margin-right: 5px;
}

.sort-section .radio-group label {
    margin-right: 15px;
    font-weight: normal;
}

/* Word Analysis tab specific styles */
.word-analysis-container {
    display: flex;
    flex-direction: column;
}

.results-group {
    margin-bottom: 20px;
}

.results-group h3 {
    margin-bottom: 10px;
}

.results-text-area {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    resize: vertical;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
    pointer-events: auto;
}

/* Make sure the loading overlay doesn't block clicks on the cancel button */
#loading-overlay * {
    pointer-events: auto;
}

.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #007bff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

#loading-message {
    color: white;
    font-size: 18px;
    margin-bottom: 20px;
}

/* Progress bar styles */
#progress-container {
    width: 100%;
    max-width: 300px;
    margin: 15px auto;
    display: none; /* Initially hidden */
}

#progress-text {
    color: white;
    text-align: center;
    margin-bottom: 5px;
    font-size: 14px;
}

#progress-bar-container {
    width: 100%;
    background-color: #444;
    border-radius: 5px;
    overflow: hidden;
    height: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#progress-bar {
    height: 20px;
    width: 0%;
    background-color: #007bff;
    transition: width 0.3s ease;
    border-radius: 5px;
}

#cancel-button {
    background-color: #dc3545;
    margin-top: 20px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 1001;
    position: relative;
    padding: 12px 25px;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

#cancel-button:hover {
    background-color: #bd2130;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.7);
}

/* Responsive styles */
@media (min-width: 768px) {
    .regex-container,
    .word-analysis-container {
        flex-direction: row;
    }

    .input-section {
        width: 40%;
        padding-right: 20px;
    }

    .results-section {
        width: 60%;
    }
}

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

    .tab-button {
        padding: 8px 15px;
        font-size: 14px;
    }

    .input-large {
        font-size: 16px;
        padding: 10px;
    }

    .results-list {
        height: 300px;
    }

    .result-item {
        padding: 4px 10px; /* Smaller height but still a good touch target width */
        line-height: 1.2;
    }

    .sort-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-section label {
        margin-bottom: 10px;
    }

    .sort-section .radio-group {
        margin-bottom: 10px;
    }
}
