* {
    box-sizing: border-box;
}

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --bg-tertiary: #fafafa;
    --bg-quaternary: #f0f0f0;
    --bg-hover: #f9f9f9;
    --text-primary: #333;
    --text-secondary: #555;
    --text-tertiary: #666;
    --text-muted: #999;
    --border-primary: #e0e0e0;
    --border-secondary: #ddd;
    --border-tertiary: #eee;
    --border-dark: #d0d0d0;
    --heading-primary: #2c3e50;
    --heading-secondary: #34495e;
    --link-color: #3498db;
    --button-primary: #3498db;
    --button-primary-hover: #2980b9;
    --button-secondary: #95a5a6;
    --button-secondary-hover: #7f8c8d;
    --button-text: white;
    --error-bg: #fadbd8;
    --error-color: #e74c3c;
    --success-color: #22c55e;
    --shadow: rgba(0,0,0,0.1);
    --code-bg: #f5f2f0;
    --code-color: #c7254e;
    --pre-bg: #2d2d2d;
    --pre-color: #f8f8f2;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-tertiary: #252525;
        --bg-quaternary: #333;
        --bg-hover: #2a2a2a;
        --text-primary: #e0e0e0;
        --text-secondary: #b0b0b0;
        --text-tertiary: #999;
        --text-muted: #666;
        --border-primary: #404040;
        --border-secondary: #3a3a3a;
        --border-tertiary: #333;
        --border-dark: #4a4a4a;
        --heading-primary: #e0e0e0;
        --heading-secondary: #d0d0d0;
        --link-color: #5dade2;
        --button-primary: #3498db;
        --button-primary-hover: #5dade2;
        --button-secondary: #5a6c7d;
        --button-secondary-hover: #6c7d8e;
        --button-text: white;
        --error-bg: #4a2b2b;
        --error-color: #ff6b6b;
        --success-color: #4ade80;
        --shadow: rgba(0,0,0,0.3);
        --code-bg: #2a2a2a;
        --code-color: #ff6b9d;
        --pre-bg: #1a1a1a;
        --pre-color: #f8f8f2;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
}

header {
    border-bottom: 2px solid var(--border-tertiary);
    padding-bottom: 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 2em;
    color: var(--heading-primary);
}

h2 {
    font-size: 1.5em;
    color: var(--heading-secondary);
    margin-top: 30px;
    margin-bottom: 15px;
}

h3 {
    font-size: 1.2em;
    color: var(--text-secondary);
    margin-top: 0;
    margin-bottom: 10px;
}

.nav {
    display: flex;
    gap: 15px;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button, .button {
    background: var(--button-primary);
    color: var(--button-text);
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}

button:hover, .button:hover {
    background: var(--button-primary-hover);
    text-decoration: none;
}

button.secondary, .button.secondary {
    background: var(--button-secondary);
}

button.secondary:hover, .button.secondary:hover {
    background: var(--button-secondary-hover);
}

input, textarea, select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-secondary);
}

pre {
    background: var(--pre-bg);
    color: var(--pre-color);
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0;
    border: 1px solid var(--border-primary);
}

/* Remove padding from pre when it contains code (highlight.js styling) */
pre:has(code) {
    padding: 0;
}

code {
    font-family: 'Courier New', monospace;
    background: var(--code-bg);
    color: var(--code-color);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Only apply block styling to code inside pre */
pre code {
    padding: 15px;
    display: block;
    background: transparent;
    color: inherit;
    border-radius: 0;
}

.file-section {
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    margin: 25px 0;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.file-section h2 {
    margin-top: 15px;
    margin-bottom: 10px;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-quaternary);
    border-bottom: 1px solid var(--border-dark);
    cursor: pointer;
}

.file-header:hover {
    background: var(--bg-hover);
}

.file-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.collapse-icon {
    font-size: 0.8em;
    color: var(--text-tertiary);
    min-width: 12px;
    font-family: Arial, Helvetica, sans-serif;
}

.file-meta {
    font-size: 0.9em;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.file-collapsed-description {
    padding: 10px 20px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    display: none;
}

.file-section.collapsed .file-collapsed-description {
    display: block;
}

.file-section.collapsed .file-body {
    display: none;
}

/* Collapsed sections keep border by default (for collapsed description) */
.file-section.collapsed .file-header {
    border-bottom: 1px solid var(--border-dark);
}

.file-description-wrapper {
    padding: 20px;
}

.file-description {
    color: var(--text-tertiary);
    margin: 0;
    padding: 15px;
    background: var(--bg-hover);
    border-left: 4px solid var(--link-color);
    border-radius: 4px;
}

.file-content {
    padding: 20px;
}

.file-download a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--bg-quaternary);
    border-radius: 4px;
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.file-download a:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.link-list {
    list-style: none;
    padding: 0;
}

.link-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-tertiary);
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.error {
    color: var(--error-color);
    background: var(--error-bg);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.description {
    color: var(--text-tertiary);
    margin: 15px 0;
    padding: 15px;
    background: var(--bg-hover);
    border-left: 4px solid var(--link-color);
}

footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-tertiary);
    color: var(--text-muted);
    font-size: 0.9em;
}

.not-found-message {
    font-size: 1.2em;
    margin: 30px 0;
}

/* Home page paste list */
.paste-list {
    list-style: none;
    padding: 0;
}

.paste-item {
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 15px;
    background: var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.paste-info {
    flex: 1;
}

.paste-title {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 5px;
}

.paste-title a {
    color: var(--heading-primary);
    text-decoration: none;
}

.paste-title a:hover {
    color: var(--link-color);
}

.paste-meta {
    font-size: 0.9em;
    color: var(--text-tertiary);
}

.paste-actions {
    display: flex;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h2 {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state-cta {
    margin-top: 20px;
}

/* Edit page */
.file-editor {
    border: 1px solid var(--border-secondary);
    padding: 15px;
    margin: 15px 0;
    border-radius: 6px;
    background: var(--bg-tertiary);
}

.file-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
    padding: 5px;
    margin: -5px -5px 10px -5px;
    border-radius: 4px;
}

.file-editor-header:hover {
    background: var(--bg-hover);
}

.file-editor-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.file-editor-header-left h3 {
    margin: 0;
}

.file-editor-names {
    color: var(--text-tertiary);
    font-size: 0.9em;
}

.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.file-editor.dragging {
    opacity: 0.5;
}

.file-editor {
    transition: opacity 0.2s;
}

.file-editor-body.drag-over {
    background: var(--bg-hover);
    border: 2px dashed var(--link-color);
    border-radius: 4px;
}

.file-hidden-indicator {
    color: var(--text-muted);
    font-size: 0.85em;
    font-style: italic;
}

.file-editor.collapsed .file-editor-body {
    display: none;
}

.inline-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* Checkbox styling */
.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-field:hover {
    background: var(--bg-quaternary);
}

.checkbox-field input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    margin: 0;
}

.checkbox-field label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

.paste-summary {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin: 5px 0;
    font-style: italic;
}

/* Fix inline form buttons to match link button heights */
.paste-actions form,
.header-actions form {
    display: inline-block;
    margin: 0;
}

.paste-actions form button,
.header-actions form button {
    margin: 0;
}

/* Ensure buttons and button-styled links have same height */
button, .button {
    line-height: 1.4;
    vertical-align: middle;
    box-sizing: border-box;
}

/* Success/error status indicators */
.status-success {
    color: var(--success-color);
}

.status-error {
    color: var(--error-color);
}

/* Image preview in file editor */
.file-image-preview {
    margin-top: 10px;
}

.file-image-preview img {
    max-width: 200px;
    max-height: 200px;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
}

/* Hidden by default elements */
.hidden {
    display: none;
}

.inline-form {
    display: inline;
}

/* Site footer */
.site-footer {
    max-width: 1200px;
    margin: 20px auto 0;
    padding: 20px 0;
    text-align: center;
}

.site-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: var(--link-color);
}

/* Paste ID Input Styles */
.paste-id-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.paste-id-input input {
    flex: 1;
}

.form-help {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Alias Management Styles */
#aliases-container {
    margin-bottom: 10px;
}

.alias-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    margin-bottom: 8px;
}

.alias-item.primary-id {
    background: var(--bg-secondary);
    border: 2px solid var(--link-color);
}

.primary-label {
    font-weight: 600;
    color: var(--link-color);
    margin-right: 5px;
}

.alias-item code {
    flex: 1;
    background: var(--pre-bg);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.alias-actions-buttons {
    display: flex;
    gap: 5px;
}

.alias-item button,
.alias-actions-buttons button {
    margin: 0;
}

button.small {
    padding: 4px 10px;
    font-size: 13px;
}

.no-aliases {
    color: var(--text-muted);
    font-style: italic;
    margin: 10px 0;
}

.alias-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.alias-error {
    margin-top: 10px;
    padding: 10px;
    background: var(--error-bg, #fee);
    color: var(--error-color, #c00);
    border: 1px solid var(--error-border, #fcc);
    border-radius: 4px;
    font-size: 14px;
}

/* Danger Button */
button.danger, .button.danger {
    background: #dc3545;
    color: white;
    border: none;
    margin-left: auto;
}

button.danger:hover, .button.danger:hover {
    background: #c82333;
}
