/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navbar */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

.navbar-nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-nav a:hover {
    color: var(--primary);
}

/* Main */
main {
    flex: 1;
    padding: 2rem 0;
}

/* Footer */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

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

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

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

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

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

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Forms */
.form {
    max-width: 600px;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
    font-family: 'Monaco', 'Menlo', monospace;
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-help code {
    background: var(--bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.back-link {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.back-link:hover {
    color: var(--primary);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section {
    margin-bottom: 3rem;
}

.section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-complete {
    border: 2px solid var(--success);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.125rem;
    margin: 0;
}

.card-header h3 a {
    color: var(--text);
    text-decoration: none;
}

.card-header h3 a:hover {
    color: var(--primary);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--bg);
    color: var(--text-muted);
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-lg {
    height: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-complete {
    background: var(--success);
}

/* Template List */
.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.template-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.template-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.template-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.template-category {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Checklist */
.checklist-progress {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.progress-text {
    font-weight: 500;
}

.progress-percent {
    color: var(--primary);
    font-weight: 600;
}

.checklist {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.checklist-section {
    margin-bottom: 2rem;
}

.checklist-section:last-of-type {
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1.125rem;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.checklist-items {
    list-style: none;
}

.checklist-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

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

.checklist-item.checked .item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.toggle-form {
    display: contents;
}

.checkbox-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
}

.checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

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

.item-text {
    flex: 1;
}

.delete-form {
    display: contents;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
}

.checklist-item:hover .btn-delete {
    opacity: 1;
}

.btn-delete:hover {
    color: var(--danger);
    background: #fef2f2;
}

/* Add Item Form */
.add-item-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.add-item-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

.add-item-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Add Section */
.add-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border);
}

.add-section-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.add-section-input {
    width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

.add-section-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Checklist Meta */
.checklist-meta {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.checklist-meta p {
    margin-bottom: 0.25rem;
}

/* Template Preview */
.template-preview {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.template-preview h2 {
    margin-bottom: 1rem;
}

.markdown-content pre {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.inline-form {
    display: inline;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .navbar-nav {
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
    }

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

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

    .add-section-form {
        flex-direction: column;
    }

    .add-section-input {
        width: 100%;
    }
}
