/**
 * BHCCO Mobile App - Refined mobile-first design
 * Professional legal research UI
 */

:root {
    --app-surface: #ffffff;
    --app-primary: #001f3f;
    --app-primary-light: #1e3a5f;
    --app-primary-soft: #e6ecf2;
    --app-accent: #ea580c;
    --app-accent-soft: #ffedd5;
    --app-green: #059669;
    --app-green-soft: #d1fae5;
    --app-purple: #1e3a5f;
    --app-purple-soft: #e6ecf2;
    --app-amber: #d97706;
    --app-amber-soft: #fef3c7;
    --app-rose: #e11d48;
    --app-rose-soft: #ffe4e6;
    --app-text: #0f172a;
    --app-text-soft: #334155;
    --app-muted: #64748b;
    --app-border: #e2e8f0;
    --app-border-light: #f1f5f9;
    --app-radius: 14px;
    --app-radius-sm: 10px;
    --app-radius-lg: 18px;
    --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --app-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --app-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --nav-height: 64px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #eef4f9;
    background: linear-gradient(180deg, #eef4f9 0%, #e6ecf2 50%, #f0f4f8 100%);
    background-attachment: fixed;
    color: var(--app-text);
    line-height: 1.55;
    padding-top: calc(56px + var(--safe-top));
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 40px);
    min-height: 100vh;
}

/* App Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: calc(56px + var(--safe-top));
    padding-top: var(--safe-top);
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 12px;
    padding-right: 12px;
}

.app-menu-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

.app-menu-btn:active {
    background: rgba(255,255,255,0.3);
}

.app-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.app-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

.app-menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    z-index: 1200;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.app-menu-drawer.open {
    transform: translateX(0);
}

.app-menu-user {
    padding: 28px 20px 24px;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
    position: relative;
}

.app-menu-user .app-menu-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    color: white;
    opacity: 0.9;
}

.app-menu-user .app-menu-close:hover {
    opacity: 1;
}

.app-menu-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.app-menu-username {
    font-size: 1.05rem;
    font-weight: 700;
}

.app-menu-email {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 4px;
}


.app-menu-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--app-muted);
    cursor: pointer;
}

.app-menu-list {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.app-menu-list li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: var(--app-text);
    text-decoration: none;
    font-weight: 500;
}

.app-menu-list li a:hover {
    background: var(--app-primary-soft);
}

.app-menu-list li a i {
    font-size: 1.2rem;
    color: var(--app-primary);
}

.app-header .logo-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    flex: 1;
    min-width: 0;
}

.logo-img-wrap {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-img-wrap img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.logo-text {
    min-width: 0;
}

.app-header .brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    display: block;
}

.app-header .brand-short {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    letter-spacing: 0.01em;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .btn-app-outline {
    border-color: rgba(255,255,255,0.8);
    color: white;
}

.app-header .btn-app-outline:hover {
    background: rgba(255,255,255,0.2);
    border-color: white;
}

    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Bottom Navigation - fixed horizontal bar at bottom */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #ffffff;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid var(--app-border-light);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    justify-items: center;
}

.app-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 4px;
    text-decoration: none;
    color: var(--app-muted);
    font-size: 0.68rem;
    font-weight: 500;
    transition: color 0.2s ease;
    min-height: 56px;
}

.app-bottom-nav a i {
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.app-bottom-nav a.active {
    color: var(--app-primary);
    font-weight: 600;
}

.app-bottom-nav a.active i {
    color: var(--app-primary);
    font-weight: 700;
}

.app-bottom-nav a:active {
    opacity: 0.7;
}

/* Search button - center with color */
.app-bottom-nav .nav-search-center {
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: #fff;
    border-radius: 10px;
    margin: 8px 2px;
    padding: 6px 4px;
    min-height: 40px;
}

.app-bottom-nav .nav-search-center i {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.app-bottom-nav .nav-search-center span {
    font-size: 0.6rem;
}

.app-bottom-nav .nav-search-center i,
.app-bottom-nav .nav-search-center span {
    color: #fff !important;
}

.app-bottom-nav .nav-search-center:active {
    opacity: 0.9;
}

/* Main content - extra bottom padding so fixed nav doesn't overlap */
.app-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 12px;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
}

/* Cards */
.app-card {
    background: var(--app-surface);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--app-border-light);
}

.app-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 14px 0;
    color: var(--app-text);
    letter-spacing: -0.02em;
}

/* Judgement HTML (RTF converted to HTML) */
.judgement-html p {
    margin: 0 0 0.85em 0;
    line-height: 1.6;
}
.judgement-html p:last-child {
    margin-bottom: 0;
}

/* Quick action grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.app-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: 16px 12px;
    background: var(--app-surface);
    border-radius: var(--app-radius-sm);
    border: 1px solid var(--app-border-light);
    box-shadow: var(--app-shadow);
    text-decoration: none;
    color: var(--app-text);
    transition: all 0.2s ease;
}

.app-grid-item:nth-child(1):hover { border-color: #93c5fd; background: #eff6ff; }
.app-grid-item:nth-child(2):hover { border-color: #c4b5fd; background: #f5f3ff; }
.app-grid-item:nth-child(3):hover { border-color: #6ee7b7; background: #ecfdf5; }
.app-grid-item:nth-child(4):hover { border-color: #fdba74; background: #fff7ed; }
.app-grid-item:nth-child(5):hover { border-color: #fcd34d; background: #fffbeb; }
.app-grid-item:nth-child(6):hover { border-color: #fda4af; background: #fff1f2; }

.app-grid-item:active {
    transform: scale(0.97);
}

.app-grid-item i {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.app-grid-item:nth-child(1) i { color: #001f3f; }
.app-grid-item:nth-child(2) i { color: #1e3a5f; }
.app-grid-item:nth-child(3) i { color: #059669; }
.app-grid-item:nth-child(4) i { color: #ea580c; }
.app-grid-item:nth-child(5) i { color: #d97706; }
.app-grid-item:nth-child(6) i { color: #e11d48; }

.app-grid-item span {
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    color: var(--app-text-soft);
}

/* Judgement cards */
.app-judgement-card {
    background: var(--app-surface);
    border-radius: var(--app-radius);
    padding: 14px;
    margin-bottom: 12px;
    border-left: 4px solid var(--app-primary);
    border-top: 1px solid var(--app-border-light);
    border-right: 1px solid var(--app-border-light);
    border-bottom: 1px solid var(--app-border-light);
    box-shadow: var(--app-shadow);
    transition: all 0.2s ease;
}

.app-judgement-card:nth-child(odd) { border-left-color: #001f3f; }
.app-judgement-card:nth-child(even) { border-left-color: #1e3a5f; }

.app-judgement-card:active {
    box-shadow: var(--app-shadow-md);
}

.app-judgement-card .judgement-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.app-judgement-card .judgement-meta span {
    font-size: 0.75rem;
    color: var(--app-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-judgement-card .judgement-meta span i {
    font-size: 0.85rem;
}

.app-judgement-card .judgement-parties {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.app-judgement-card .judgement-parties .vs {
    font-weight: 500;
    color: var(--app-muted);
    margin: 0 4px;
}

.app-judgement-card .search-preview {
    font-size: 0.85rem;
    color: var(--app-text-soft);
    line-height: 1.5;
}

.app-judgement-card .search-preview mark {
    background: var(--app-amber-soft);
    color: var(--app-amber);
    padding: 0 2px;
    border-radius: 2px;
}

.app-judgement-card .judgement-advocate {
    font-size: 0.8rem;
    color: var(--app-muted);
    margin-bottom: 14px;
}

.app-judgement-card .btn-view {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
    border: none;
    border-radius: var(--app-radius-sm);
    text-decoration: none;
    transition: all 0.2s;
}

.app-judgement-card .btn-view:hover {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 31, 63, 0.4);
}

.app-judgement-card .btn-view:active {
    transform: scale(0.98);
}

/* Section titles */
.app-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 14px 0;
    color: var(--app-text);
    letter-spacing: -0.01em;
}

/* Buttons */
.btn-app {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--app-radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-app:active {
    transform: scale(0.98);
}

.btn-app-primary {
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
}

.btn-app-primary:hover {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 31, 63, 0.35);
}

.btn-app-outline {
    background: transparent;
    color: var(--app-primary);
    border: 2px solid var(--app-primary);
}

.btn-app-outline:hover {
    background: var(--app-primary-soft);
    box-shadow: 0 2px 8px rgba(0, 31, 63, 0.2);
}

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

.btn-sm {
    min-height: 30px;
    padding: 5px 12px;
    font-size: 0.78rem;
}

/* Form inputs */
.form-app input,
.form-app select,
.form-app textarea {
    width: 100%;
    min-height: 40px;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    margin-bottom: 18px;
    background: var(--app-surface);
    -webkit-appearance: none;
    appearance: none;
}

.form-app textarea {
    min-height: 80px;
    resize: vertical;
}

.form-app input::placeholder,
.form-app textarea::placeholder {
    color: var(--app-muted);
}

.form-app input:focus,
.form-app select:focus,
.form-app textarea:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(0, 31, 63, 0.15);
}

.form-app label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--app-text-soft);
}

/* List items */
.app-list-item {
    display: flex;
    padding: 16px;
    background: var(--app-surface);
    border-radius: var(--app-radius-sm);
    margin-bottom: 12px;
    border: 1px solid var(--app-border-light);
    box-shadow: var(--app-shadow);
}

.app-list-item .icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

/* Book cards */
.app-book-card {
    display: flex;
    gap: 16px;
    padding: 18px;
    background: var(--app-surface);
    border-radius: var(--app-radius);
    margin-bottom: 14px;
    border: 1px solid var(--app-border-light);
    box-shadow: var(--app-shadow);
}

.app-book-card .cover {
    width: 64px;
    height: 88px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.app-book-card .cover-placeholder {
    width: 64px;
    height: 88px;
    border-radius: 10px;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Flash messages */
.app-flash {
    margin: 12px 12px;
    padding: 14px 18px;
    border-radius: var(--app-radius-sm);
    font-size: 0.9rem;
}

.app-flash-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.app-flash-error {
    background: #fff1f2;
    color: #991b1b;
    border: 1px solid #fecdd3;
}

/* Auth */
.app-auth {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 12px;
}

.app-auth .app-card {
    padding: 22px 18px;
}

.login-card {
    border: 2px solid rgba(0, 31, 63, 0.2);
    box-shadow: 0 8px 24px rgba(0, 31, 63, 0.15);
}

/* Profile badge */
.app-profile-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Menu list items */
.app-list-item {
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
}

.app-list-item:hover {
    box-shadow: var(--app-shadow-md);
}

.app-list-item > div:nth-child(2) {
    flex-grow: 1;
    min-width: 0;
}

.app-list-item .bi-chevron-right,
.app-list-item .bi-box-arrow-up-right {
    font-size: 1.1rem;
    color: var(--app-muted);
    flex-shrink: 0;
}

/* Court cards */
.app-court-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--app-surface);
    border-radius: var(--app-radius);
    margin-bottom: 14px;
    border: 1px solid var(--app-border-light);
    box-shadow: var(--app-shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.app-court-card:hover {
    border-color: #c4b5fd;
    box-shadow: 0 4px 16px rgba(0, 31, 63, 0.2);
}

.app-court-card .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #001f3f 0%, #1e3a5f 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.app-court-card .icon-wrap {
    transition: transform 0.2s;
}

.app-court-card:hover .icon-wrap {
    transform: scale(1.05);
}

/* Empty state */
.app-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--app-muted);
}

.app-empty i {
    font-size: 2.8rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.app-empty p {
    font-size: 0.95rem;
}

/* Utilities */
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.flex-grow-1 { flex-grow: 1; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.text-secondary { color: var(--app-muted); }
.small { font-size: 0.85rem; }
.text-success { color: #059669; }
.badge { display: inline-block; padding: 0.25rem 0.5rem; font-size: 0.75rem; border-radius: 6px; }
.bg-primary { background: var(--app-primary); color: white; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
