/* Base Variables */
:root {
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --secondary: #A78BFA;
    --accent: #10B981;
    --bg-color: #0F172A;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-hover: rgba(30, 41, 59, 0.9);
    --border: rgba(139, 92, 246, 0.2);
    --text-active: #F8FAFC;
    --text-muted: #94A3B8;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-active);
    min-height: 100vh;
    background-image: radial-gradient(circle at top right, rgba(139, 92, 246, 0.1), transparent 400px),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent 400px);
}

/* Utilities */
.glass {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.text-muted {
    color: var(--text-muted);
}

.mt-3 {
    margin-top: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-outline {
    border: 1px solid var(--border);
    color: var(--text-active);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--secondary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-active);
    font-size: 0.95rem;
    transition: var(--transition);
    resize: vertical;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 360px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    border-top: none;
    border-bottom: none;
    border-left: none;
    border-radius: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.template-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.template-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: var(--transition);
}

.template-card:hover {
    background: rgba(139, 92, 246, 0.05);
}

.template-card.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
    color: var(--secondary);
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.nav-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.version-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

/* Editor Container */
.editor-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 16px;
}

.sop-editor {
    width: 100%;
    max-width: 800px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Document Formatting */
.doc-section {
    margin-bottom: 32px;
}

.doc-section h1.edit-string {
    font-size: 2.5rem;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 16px;
    color: var(--primary);
    outline: none;
}

.doc-section h2.edit-string {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--secondary);
    outline: none;
}

.doc-section p.edit-string {
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 16px;
    outline: none;
}

.edit-string:focus {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 2px 4px;
}

/* Steps */
.step-list {
    list-style: none;
    counter-reset: sop-counter;
}

.step-item {
    position: relative;
    padding-left: 48px;
    margin-bottom: 20px;
}

.step-item::before {
    counter-increment: sop-counter;
    content: counter(sop-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.step-content {
    line-height: 1.6;
    outline: none;
    padding: 6px 0;
}

/* Warnings / Notes */
.callout {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.callout.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning);
}

.callout.info {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--accent);
}

/* Output Display (Print) */
.print-container {
    display: none;
    background: white;
    color: black;
    padding: 40px;
}

@media print {
    .no-print {
        display: none !important;
    }

    body,
    html {
        background: white !important;
        color: black !important;
        height: auto;
        min-height: auto;
    }

    .print-container {
        display: block;
        max-width: 800px;
        margin: 0 auto;
    }

    .print-container h1 {
        color: black !important;
        border-bottom: 2px solid #ccc;
    }

    .print-container h2 {
        color: #333 !important;
    }

    .print-container .step-item::before {
        background: #f0f0f0;
        border-color: #666;
        color: black;
    }

    .callout {
        border: 1px solid #ddd;
        border-left-width: 4px;
        background: #f9f9f9 !important;
    }
}