:root {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(203, 213, 225, 0.6);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --input-bg: rgba(255, 255, 255, 0.9);
    --success: #10b981;
    --font-family: 'Outfit', sans-serif;
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 20%);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 24px;
    gap: 24px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo ion-icon {
    color: var(--primary-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Main Layout */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.view-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    height: 100%;
    min-height: 0;
}

.list-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    /* Enable internal scrolling */
}

.detail-pane {
    display: flex;
    flex-direction: column;
    padding: 0;
    /* Reset padding for cleaner doc containment */
    overflow: hidden;
}

.document-view {
    padding: 32px;
    overflow-y: auto;
    height: 100%;
}

.empty-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.empty-detail ion-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Document Typography */
.doc-header {
    border-bottom: 2px solid var(--card-border);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.doc-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.doc-id {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.doc-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.doc-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.doc-section {
    margin-bottom: 24px;
}

.doc-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.doc-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    white-space: pre-wrap;
    /* Preserve line breaks */
    background: rgba(255, 255, 255, 0.5);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.doc-tags {
    display: flex;
    gap: 8px;
    margin-top: 32px;
}

.tag-badge {
    font-size: 0.8rem;
    background: var(--card-border);
    padding: 4px 12px;
    border-radius: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* overflow: hidden; Removed to allow sticky headers if needed, but keeping for now */
    box-shadow: var(--shadow);
    height: 100%;
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Global Form & Button Styles (Un-nested) */
form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input,
textarea {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    width: 100%;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--card-border);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-main);
}

/* Search Area */
.search-bar {
    position: relative;
    width: 100%;
}

.search-bar ion-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding-left: 40px;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 8px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state ion-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Incident Card */
.incident-card {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.incident-card:hover {
    background: white;
    box-shadow: var(--shadow);
    transform: translateX(4px);
    border-color: var(--primary-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.jira-id {
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 8px;
    border-radius: 4px;
}

.card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.card-preview {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-color);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: translateY(0);
    transition: transform 0.2s;
    border: 1px solid var(--card-border);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}