/* Work Log - Main Stylesheet */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --success-color: #16a34a;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --sidebar-width: 280px;
}

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

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

/* Header */
.site-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

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

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-color);
    background-color: transparent;
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
}

.nav-link:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-form {
    display: inline;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 1.5rem;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

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

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

.btn-secondary:hover {
    background-color: #d1d5db;
}

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

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

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.validation-summary {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger-color);
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.validation-message {
    color: var(--danger-color);
    font-size: 0.75rem;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.auth-card {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.info-box {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Dashboard layout */
.dashboard-layout {
    display: flex;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 200px);
    align-items: flex-start;
}

.hierarchy-panel {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    overflow-y: auto;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
}

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

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* Tree hierarchy styles */
.hierarchy-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-root {
    padding: 0;
}

.tree-children {
    padding-left: 1rem;
    margin-top: 0.125rem;
}

.tree-node {
    margin-bottom: 0.125rem;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: background-color 0.1s ease;
}

.tree-item:hover {
    background-color: var(--bg-color);
}

.tree-item.selected {
    background-color: var(--primary-color);
    color: white;
}

.tree-icon {
    font-size: 0.625rem;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.tree-leaf .tree-icon {
    font-size: 0.875rem;
}

.empty-message {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Content panel */
.content-panel {
    flex: 1;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.day-header h1 {
    font-size: 1.5rem;
}

.day-summary {
    display: flex;
    gap: 1rem;
}

.total-hours {
    font-weight: 600;
    color: var(--primary-color);
}

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

/* Session cards */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.session-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.session-time {
    font-weight: 600;
    color: var(--primary-color);
}

.session-actions {
    display: flex;
    gap: 0.5rem;
}

.session-actions a.btn {
    color: var(--primary-color);
    font-weight: bold;
}

.session-actions a.btn:hover {
    color: var(--primary-hover);
    font-weight: bold;
}

.session-description {
    margin-bottom: 0.75rem;
}

.session-notes,
.session-next {
    font-size: 0.875rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.session-notes strong,
.session-next strong {
    color: var(--text-muted);
}

.session-next {
    background-color: #eff6ff;
    border-radius: 0.25rem;
    padding: 0.5rem;
    border: none;
}

.session-notes-content p,
.session-notes-content ul,
.session-notes-content ol,
.session-notes-content pre {
    margin: 0.35rem 0;
}

.session-notes-content ul,
.session-notes-content ol {
    padding-left: 1.25rem;
}

.session-notes-content :not(pre) > code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
    background-color: rgba(107, 114, 128, 0.15);
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
}

.session-notes-content pre {
    overflow-x: auto;
    border-radius: 0.5rem;
}

.delete-form {
    display: inline;
}

/* Empty states */
.empty-state,
.welcome-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.welcome-message h1 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.empty-state .btn,
.welcome-message .btn {
    margin-top: 1rem;
}

/* Form container */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-card {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-card h1 {
    margin-bottom: 1.5rem;
}

/* Tag badge */
.tag-badge {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.session-header .tag-badge {
    margin-right: auto;
    margin-left: 0.75rem;
}

/* Tag totals strip at bottom of sessions panel */
.tag-totals-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 0.5rem 0.5rem;
    margin-top: 1rem;
}

.tag-totals-label {
    font-weight: 600;
    color: var(--text-color);
    margin-right: 0.25rem;
}

.tag-total-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tag input row */
.tag-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.tag-input-row .form-control {
    flex: 1;
}

/* Tag create form in modal */
.tag-create-form {
    margin-bottom: 1.5rem;
}

/* Tag list in modal */
.tag-list {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.tag-item + .tag-item {
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .hierarchy-panel {
        width: 100%;
        position: static;
        max-height: none;
    }

    .hierarchy-section.indented,
    .hierarchy-section.indented-2,
    .hierarchy-section.indented-3 {
        padding-left: 0.5rem;
    }

    .tag-input-row {
        flex-direction: column;
    }

    .tag-input-row .btn {
        width: 100%;
    }
}

/* Modal styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

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

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

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Dark mode - auto-detect system preference */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #3b82f6;
        --primary-hover: #2563eb;
        --danger-color: #ef4444;
        --danger-hover: #dc2626;
        --success-color: #22c55e;
        --text-color: #f3f4f6;
        --text-muted: #9ca3af;
        --bg-color: #111827;
        --card-bg: #1f2937;
        --border-color: #374151;
    }

    /* Form inputs in dark mode */
    .form-control {
        background-color: var(--bg-color);
        color: var(--text-color);
        border-color: var(--border-color);
    }

    .form-control:focus {
        border-color: var(--primary-color);
        background-color: var(--bg-color);
    }

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

    /* Next planned stage info box in dark mode */
    .session-next {
        background-color: #1e3a5f;
    }

    /* Selected hierarchy items */
    .hierarchy-list li a:hover {
        background-color: var(--border-color);
    }

    /* Tag badge slightly lighter in dark mode for contrast */
    .tag-badge {
        background-color: var(--primary-color);
    }

    /* Validation messages */
    .validation-summary,
    .validation-message {
        color: var(--danger-color);
    }

    .session-notes-content :not(pre) > code {
        background-color: rgba(156, 163, 175, 0.2);
    }
}
