:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --code-bg: #0f172a;
    color-scheme: dark;
}

/* Light mode */
[data-theme="light"] {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --code-bg: #f1f5f9;
    color-scheme: light;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Desktop two-column layout */
@media (min-width: 1200px) {
    .two-column-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        align-items: start;
    }
    
    .two-column-wrapper > .section {
        margin-bottom: 0;
    }
    
    .form-inline-sections {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        align-items: start;
        margin-bottom: 1.5rem;
    }
    
    .form-inline-sections > .section {
        margin-bottom: 0;
        height: fit-content;
    }
    
    .form-inline-sections .right-column {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .form-inline-sections .right-column > .section {
        margin-bottom: 0;
    }
}

.submit-section {
    margin-top: 2rem;
}

/* Explanation Tab Styles */
.explanation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.explanation-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
}

.explanation-item h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.explanation-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.explanation-item p:last-child {
    margin-bottom: 0;
}

.explanation-item ul {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    padding-left: 1.25rem;
    margin: 0.5rem 0 0 0;
}

.explanation-item li {
    margin-bottom: 0.25rem;
}

.explanation-item code {
    background: var(--background);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    color: var(--primary-color);
}

#explanation .section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.best-practices-list {
    list-style: none;
    padding: 0;
}

.best-practices-list li {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.best-practices-list li:last-child {
    margin-bottom: 0;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

@media (min-width: 1200px) {
    header {
        margin-bottom: 2rem;
        padding: 1rem 0;
    }
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.theme-toggle {
    position: absolute;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.25rem;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 1rem 2rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* Sections */
.section {
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

@media (min-width: 1200px) {
    .section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .section h2 {
        margin-bottom: 1rem;
        font-size: 1.25rem;
    }
}

.section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Template Grid */
.template-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.template-grid .template-card {
    flex: 1 1 180px;
}

@media (min-width: 1200px) {
    .template-grid {
        gap: 0.75rem;
    }
    
    .template-grid .template-card {
        flex: 1 1 calc(20% - 0.75rem);
    }
    
    .template-card {
        padding: 1rem;
    }
    
    .template-card h3 {
        font-size: 1rem;
    }
}

.template-card {
    padding: 1.5rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.template-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.template-card.selected {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.template-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.template-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.template-card small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

@media (min-width: 1200px) {
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-group:last-child {
        margin-bottom: 0;
    }
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.required {
    color: var(--danger-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

/* Checkboxes */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* More compact checkbox grid in two-column layout */
@media (min-width: 1200px) {
    .two-column-wrapper .checkbox-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .two-column-wrapper .checkbox-label {
        padding: 0.75rem;
    }
}

.checkbox-label {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.3s;
}

.checkbox-label:hover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.checkbox-label-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

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

.checkbox-label span {
    font-weight: 600;
}

.checkbox-label small {
    margin-top: 0;
    margin-left: 1.75rem;
}

/* SAN Entries */
#sanContainer {
    margin-bottom: 1rem;
}

.san-entry {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.san-entry select {
    width: 150px;
}

.san-entry input {
    flex: 1;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-remove {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

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

.btn-secondary:hover {
    background: #475569;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    padding: 0.5rem 1rem;
}

.btn-remove:hover {
    background: #dc2626;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
}

/* Result Boxes */
.result-box {
    margin-bottom: 2rem;
}

.result-box h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.result-box textarea {
    margin-bottom: 1rem;
}

.result-box button {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Info and Warning Boxes */
.info-box {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
}

.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning-color);
    padding: 1rem;
    margin-top: 1rem;
    border-radius: 0.375rem;
}

.success-box {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0.375rem;
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0.375rem;
}

/* Analysis Results */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 1200px) {
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .analysis-grid {
        grid-template-columns: 1fr;
    }
}

.analysis-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 0;
}

.analysis-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.analysis-section h4 {
    color: var(--text);
    font-size: 0.9rem;
    margin: 1rem 0 0.5rem 0;
}

.analysis-section h4:first-of-type {
    margin-top: 0;
}

.analysis-section ul {
    margin: 0;
    padding-left: 1.25rem;
    list-style: disc;
}

.analysis-section li {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.eku-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.eku-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--background);
    border-radius: 0.375rem;
    border: 1px solid var(--border);
}

.eku-item .eku-name {
    font-weight: 500;
    color: var(--text);
}

.eku-item .eku-oid {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

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

.analysis-table th {
    background: var(--background);
    font-weight: 600;
}

.analysis-table code {
    background: var(--code-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Info list (definition list style) */
.info-list {
    margin: 0;
    padding: 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
}

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

.info-item dt {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.info-item dd {
    margin: 0;
}

.info-item dd code {
    background: var(--code-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    display: inline-block;
    word-break: break-word;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    margin-top: 4rem;
}

/* Custom EKU List */
#customEKUList {
    margin-top: 1rem;
}

.custom-eku-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--background);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.custom-eku-item code {
    flex: 1;
    padding: 0.25rem 0.5rem;
    background: var(--code-bg);
    border-radius: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .template-grid .template-card {
        flex: 1 1 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .tab-button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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