:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px 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);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header Styles */
.app-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-dark);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Controls (regulation picker + upload) */
.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reg-picker {
    position: relative;
    display: flex;
    align-items: center;
}

.reg-picker-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.reg-select {
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.625rem 2.25rem 0.625rem 2.5rem;
    min-width: 260px;
    max-width: 420px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.reg-select:hover:not(:disabled) {
    border-color: var(--primary-color);
}

.reg-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.reg-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hidden-input {
    display: none;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--surface-color);
    color: var(--primary-dark);
    border: 1px solid var(--border-color);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.upload-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.doc-badge {
    display: inline-block;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
}

@media (max-width: 720px) {
    .header-content { flex-wrap: wrap; gap: 0.75rem; }
    .reg-select { min-width: 180px; }
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.main-layout.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.toc-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.toc-item {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
    color: var(--text-main);
    font-size: 0.875rem;
    text-decoration: none;
    display: block;
}

.toc-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.toc-item.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 500;
}

.toc-indent-1 { padding-left: 1.5rem; }
.toc-indent-2 { padding-left: 2.25rem; }

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: var(--bg-color);
    scroll-behavior: smooth;
}

.document-header {
    background-color: var(--surface-color);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    text-align: center;
}

.doc-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    line-height: 1.3;
}

.doc-subtitle {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-muted);
}

.doc-meta {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Document Sections */
.doc-section {
    background-color: var(--surface-color);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.doc-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* Hierarchy Styling */
.bab-container { margin-bottom: 3rem; }
.bab-title {
    text-align: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.pasal-container {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #fafafa;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.pasal-title {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}

.pasal-content { margin-bottom: 1rem; }

.ayat-list {
    list-style-type: none;
    padding-left: 1rem;
}

.ayat-item {
    margin-bottom: 0.75rem;
    display: flex;
}

.ayat-number {
    font-weight: 500;
    min-width: 2rem;
}

.huruf-list {
    list-style-type: none;
    padding-left: 2rem;
    margin-top: 0.5rem;
}

.huruf-item {
    margin-bottom: 0.5rem;
    display: flex;
}

.huruf-char {
    min-width: 2rem;
}

.angka-list {
    list-style-type: none;
    padding-left: 2.5rem;
    margin-top: 0.5rem;
}

.angka-item {
    margin-bottom: 0.5rem;
    display: flex;
}

.angka-num {
    min-width: 1.5rem;
}

.penjelasan {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--primary-light);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 73px);
    text-align: center;
    padding: 2rem;
}

.empty-state.hidden {
    display: none;
}

.empty-state-icon {
    width: 96px;
    height: 96px;
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    max-width: 400px;
}

/* Utilities */
.hidden { display: none !important; }

/* Menimbang & Mengingat */
.pembukaan-section { margin-bottom: 1.5rem; }
.pembukaan-title { font-weight: 600; margin-bottom: 0.5rem; }
.pembukaan-list { padding-left: 1.5rem; }
.pembukaan-list li { margin-bottom: 0.5rem; }
