:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --border-color: #cccccc;
    --accent-primary: #0066cc;
    --accent-hover: #0052a3;
    --button-bg: #f0f0f0;
    --button-hover: #e0e0e0;
    --focus-outline: #0066cc;
    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #3a3a3a;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --border-color: #4a4a4a;
    --accent-primary: #4d9fff;
    --accent-hover: #3385ff;
    --button-bg: #2a2a2a;
    --button-hover: #3a3a3a;
    --focus-outline: #4d9fff;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background-color: var(--accent-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 600;
    z-index: 3000;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

.loading-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Header */
header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Document Selector */
.document-selector {
    position: relative;
}

#document-select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--button-bg);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="12" height="8"%3E%3Cpath fill="%23666" d="M0 0l6 8 6-8z"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    min-width: 180px;
}

#document-select:hover {
    background-color: var(--button-hover);
    border-color: var(--accent-primary);
}

#document-select:focus-visible {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

#document-select option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

/* Left Sidebar - Pattern Library */
.sidebar-left {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
}

.pattern-group {
    margin-bottom: 1.5rem;
}

.pattern-group h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.pattern-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Editor Area */
.editor-container {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
    min-height: 0;
}

.editor-toolbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-body {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

#highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.5rem 4.5rem 1.5rem 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: transparent;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
    z-index: 1;
}

.validation-warnings {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ff9800;
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 0.875rem;
    color: #856404;
}

[data-theme="dark"] .validation-warnings {
    background-color: #3d3200;
    border-color: #ffc107;
    color: #ffc107;
}

.validation-warnings strong {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.validation-warnings ul {
    margin: 0;
    padding-left: 1.5rem;
    list-style-type: none;
}

.validation-warnings li {
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.validation-warnings li:before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background-color: currentColor;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Syntax highlight colors */
.hl-metadata { color: #565e67; } /* Grey - WCAG AA compliant */
.hl-structure { color: #2563eb; } /* Blue */
.hl-interaction { color: #137939; } /* Green - WCAG AA compliant */
.hl-layout { color: #7c3aed; } /* Purple */
.hl-default { color: var(--text-primary); }

/* Dark mode syntax colors - WCAG AA compliant */
[data-theme="dark"] .hl-metadata { color: #a8abb0; }
[data-theme="dark"] .hl-structure { color: #7ca5f5; }
[data-theme="dark"] .hl-interaction { color: #4ade80; }
[data-theme="dark"] .hl-layout { color: #c084fc; }

/* Category button colors */
.pattern-btn.category-metadata { color: #565e67; border-color: #565e67; }
.pattern-btn.category-metadata:hover { background-color: #f3f4f6; border-color: #4b5563; }
.pattern-btn.category-structure { color: #2563eb; border-color: #2563eb; }
.pattern-btn.category-structure:hover { background-color: #eff6ff; border-color: #1d4ed8; }
.pattern-btn.category-interaction { color: #137939; border-color: #137939; }
.pattern-btn.category-interaction:hover { background-color: #f0fdf4; border-color: #166534; }
.pattern-btn.category-layout { color: #7c3aed; border-color: #7c3aed; }
.pattern-btn.category-layout:hover { background-color: #faf5ff; border-color: #6d28d9; }

/* Dark mode button colors - WCAG AA compliant */
[data-theme="dark"] .pattern-btn.category-metadata { color: #a8abb0; border-color: #a8abb0; }
[data-theme="dark"] .pattern-btn.category-metadata:hover { background-color: #374151; }
[data-theme="dark"] .pattern-btn.category-structure { color: #7ca5f5; border-color: #7ca5f5; }
[data-theme="dark"] .pattern-btn.category-structure:hover { background-color: #1e3a8a; }
[data-theme="dark"] .pattern-btn.category-interaction { color: #4ade80; border-color: #4ade80; }
[data-theme="dark"] .pattern-btn.category-interaction:hover { background-color: #14532d; }
[data-theme="dark"] .pattern-btn.category-layout { color: #c084fc; border-color: #c084fc; }
[data-theme="dark"] .pattern-btn.category-layout:hover { background-color: #5b21b6; }

.editor-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#wireframe-editor {
    flex: 1;
    padding: 1.5rem 4.5rem 1.5rem 1.5rem;
    border: none;
    background-color: transparent;
    color: transparent;
    caret-color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

#line-numbers {
    position: absolute;
    top: 0;
    right: 0.5rem;
    bottom: 0;
    width: 3rem;
    padding: 1.5rem 0.5rem 1.5rem 0.5rem;
    text-align: right;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    opacity: 0.65;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
    background: transparent;
}

/* Buttons */
button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--button-bg);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

button:hover {
    background-color: var(--button-hover);
    border-color: var(--accent-primary);
}

button:active {
    transform: scale(0.98);
}

button:focus-visible {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.pattern-btn {
    padding: 0.4rem 0.75rem;
    text-align: left;
    font-size: 0.8125rem;
}

/* File Input */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--accent-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px var(--shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 1000;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Theme Toggle */
.theme-toggle {
    background-color: var(--button-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background-color: var(--button-hover);
}

/* Help Icon */
.help-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
}

/* Offline Indicator */
.offline-banner {
    background-color: #dc3545;
    color: white;
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 500;
    font-size: 0.875rem;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.offline-banner.show {
    display: flex;
}

.offline-icon {
    font-size: 1rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: transparent;
}

.modal-body {
    padding: 1.5rem;
    line-height: 1.6;
}

.modal-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-body ul, .modal-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-body strong {
    color: var(--accent-primary);
}

.modal-body code {
    background-color: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875em;
}

.modal-body label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.modal-body textarea,
.modal-body input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
    resize: vertical;
}

.modal-body textarea:focus,
.modal-body input[type="text"]:focus {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.share-network-btn {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--button-bg);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.share-network-btn:hover {
    background-color: var(--button-hover);
}

.share-network-btn:focus-visible {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
}

.share-network-btn.linkedin-btn {
    background-color: #0077b5;
    color: white;
    border-color: #0077b5;
}

.share-network-btn.linkedin-btn:hover {
    background-color: #005582;
}

.share-network-btn.mastodon-btn {
    background-color: #6364ff;
    color: white;
    border-color: #6364ff;
}

.share-network-btn.mastodon-btn:hover {
    background-color: #4a4bd9;
}

.share-network-btn.bluesky-btn {
    background-color: #1185fe;
    color: white;
    border-color: #1185fe;
}

.share-network-btn.bluesky-btn:hover {
    background-color: #0d6bd1;
}

.share-network-btn.copy-btn {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.share-network-btn.copy-btn:hover {
    background-color: var(--accent-hover);
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.comparison-table th,
.comparison-table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.comparison-table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .header-actions {
        width: 100%;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
