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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    line-height: 1.6;
}

h1, h2, h3 {
    color: #a0cfee;
    margin-bottom: 16px;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }

/* --- Layout --- */
.container {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
}

.panel {
    padding: 32px;
    flex: 1 1 500px;
}

.controls {
    background-color: #2a2a2a;
    border-right: 1px solid #444;
}

/* --- Forms and Controls --- */
.input-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 16px;
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
}

textarea {
    min-height: 200px;
    resize: vertical;
}

.flags {
    margin-bottom: 24px;
}

.flags label {
    display: inline-block;
    margin-right: 16px;
    font-weight: normal;
}

button {
    display: inline-block;
    padding: 16px 24px;
    background-color: #a0cfee;
    color: #1a1a1a;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #b8dff8;
}

/* --- Results --- */
.error {
    color: #ff8a8a;
    background-color: rgba(255, 138, 138, 0.1);
    border: 1px solid #ff8a8a;
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    display: none; /* Hidden by default */
}

.highlighted-output {
    background-color: #2a2a2a;
    padding: 16px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', Courier, monospace;
    min-height: 50px;
}

mark {
    background-color: #f1c40f;
    color: #333;
    border-radius: 3px;
    padding: 2px 4px;
}

#match-list, #extracted-list {
    list-style-type: none;
    padding-left: 0;
}

#match-list li, #extracted-list li {
    background-color: #2a2a2a;
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-family: 'Courier New', Courier, monospace;
}

/* --- Cheatsheet --- */
.cheatsheet-toggle {
    margin-top: 24px;
}

.cheatsheet-toggle a {
    color: #a0cfee;
    text-decoration: none;
}

.cheatsheet {
    background-color: #2a2a2a;
    padding: 32px;
    border-top: 1px solid #444;
}

.cheatsheet.hidden {
    display: none;
}

.cheatsheet ul {
    list-style-type: none;
    columns: 2;
}

.cheatsheet li {
    margin-bottom: 8px;
}

.cheatsheet code {
    background-color: #333;
    padding: 2px 4px;
    border-radius: 3px;
    color: #f1c40f;
}

/* --- Responsive --- */
@media (max-width: 800px) {
    .container {
        flex-direction: column;
    }
    .controls {
        border-right: none;
        border-bottom: 1px solid #444;
    }
    .cheatsheet ul {
        columns: 1;
    }
}

/* --- Content Section --- */
.content-section {
    padding: 32px;
    background-color: #1a1a1a;
    border-top: 1px solid #444;
    display: block;
}

.content-section h2 {
    color: #a0cfee;
    margin-top: 24px;
}

.content-section p, .content-section ol {
    margin-bottom: 16px;
}

.content-section ol {
    padding-left: 20px;
}

/* --- Header and Footer --- */
.main-header, .main-footer {
    background-color: #2a2a2a;
    padding: 16px 32px;
    border-bottom: 1px solid #444;
}

.main-header .container, .main-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: auto;
}

.logo {
    color: #a0cfee;
    text-decoration: none;
    font-size: 24px;
    font-weight: bold;
}

.main-nav ul {
    list-style-type: none;
}

.main-nav ul li {
    display: inline-block;
    margin-left: 24px;
}

.main-nav a {
    color: #f0f0f0;
    text-decoration: none;
    font-size: 18px;
}

.main-footer {
    border-top: 1px solid #444;
    border-bottom: none;
}

.main-footer ul {
    list-style-type: none;
}

.main-footer ul li {
    display: inline-block;
    margin-left: 24px;
}

.main-footer a {
    color: #a0cfee;
    text-decoration: none;
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #2a2a2a;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 4px;
    position: relative;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

#library-list {
    list-style-type: none;
    padding: 0;
}

#library-list li {
    padding: 12px;
    border-bottom: 1px solid #444;
}

#library-list li:last-child {
    border-bottom: none;
}

#library-list .regex-desc {
    font-weight: bold;
    color: #a0cfee;
}

#library-list .regex-pattern {
    font-family: 'Courier New', Courier, monospace;
    color: #f0f0f0;
    margin-top: 8px;
    display: block;
}

#library-list .library-actions {
    float: right;
}

.small-btn {
    padding: 4px 8px;
    font-size: 12px;
    margin-left: 8px;
}

.modal-footer {
    margin-top: 24px;
    text-align: right;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    border-bottom: 1px solid #444;
    margin-bottom: 16px;
}

.tab-link {
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    color: #ccc;
    font-size: 16px;
}

.tab-link.active {
    color: #a0cfee;
    border-bottom: 2px solid #a0cfee;
}

.tab-content {
    display: none;
}

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

.visualization-output {
    background-color: #2a2a2a;
    padding: 16px;
    border-radius: 4px;
    min-height: 100px;
}

/* --- Regex Visualization --- */
.regex-token {
    display: inline-block;
    padding: 8px;
    margin: 4px;
    border-radius: 4px;
    background-color: #333;
    border: 1px solid #555;
}

.regex-token.group {
    background-color: #444;
    border-color: #666;
}

.regex-token.meta {
    color: #f1c40f;
}

.regex-token.quantifier {
    color: #a0cfee;
}

/* --- Social Share Buttons --- */
.share-container {
    position: relative;
    display: inline-block;
}

.share-dropdown-content {
    display: none;
    position: absolute;
    background-color: #2a2a2a;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 4px;
}

.share-dropdown-content a {
    color: #f0f0f0;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.share-dropdown-content a:hover {background-color: #444;}

.share-container:hover .share-dropdown-content {
    display: block;
}

.nav-btn {
    background: none;
    border: none;
    color: #f0f0f0;
    font-size: 18px;
    cursor: pointer;
}
