/* ============================================================
   CyberLaw Bot
   Premium dark theme with gold accents
   ============================================================ */

/* ── Theme tokens ── */
:root {
    --bg-deep: #0b0d17;
    --bg-base: #101325;
    --bg-surface: rgba(17, 19, 33, 0.92);
    --bg-card: rgba(22, 25, 44, 0.85);
    --bg-hover: rgba(30, 34, 58, 0.9);

    --gold: #c9a84c;
    --gold-light: #e8cf7a;
    --gold-glow: rgba(201, 168, 76, 0.25);
    --blue: #5b8def;
    --blue-glow: rgba(91, 141, 239, 0.18);
    --green: #34d399;
    --red: #f87171;

    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f636a;

    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.10);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-urdu: 'Noto Nastaliq Urdu', serif;

    --header-h: 64px;
    --input-h: 140px;
    --max-w: 820px;
}

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-deep);
    background: linear-gradient(170deg, #0b0d17 0%, #101325 40%, #0f1120 100%);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App shell ── */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
}

/* ── Header ── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 24px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 0 8px var(--gold-glow));
}

.header-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-text .subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--gold);
    box-shadow: 0 0 16px var(--gold-glow);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 100px;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.15);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-label {
    font-size: 0.7rem;
    color: var(--green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── Chat area ── */
.chat-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scroll-behavior: smooth;
}

/* ── Welcome screen ── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100%;
    padding: 40px 24px 60px;
    position: relative;
}

.welcome-glow {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.5;
}

.welcome-icon {
    font-size: 56px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px var(--gold-glow));
    animation: float 4s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-screen h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.gold {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 440px;
    margin-bottom: 40px;
    line-height: 1.7;
    position: relative;
    z-index: 1;
}

/* ── Suggestion cards ── */
.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 560px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.suggestion-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-sans);
    transition: all 0.25s ease;
}

.suggestion-card:hover {
    border-color: var(--gold);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 24px var(--gold-glow), 0 0 0 1px var(--gold);
}

.sug-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.sug-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.suggestion-card:hover .sug-text {
    color: var(--text-primary);
}

/* ── Messages ── */
.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px 0;
    max-width: var(--max-w);
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 12px;
    padding: 0 24px;
    animation: msg-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User message */
.user-message {
    justify-content: flex-end;
}

.user-message .bubble {
    background: linear-gradient(135deg, #1a3a5c, #1e3d62);
    border: 1px solid rgba(91, 141, 239, 0.15);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
    max-width: 75%;
    padding: 14px 20px;
    font-size: 0.93rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* AI message */
.ai-message {
    align-items: flex-start;
}

.ai-message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-message .bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg);
    max-width: 80%;
    padding: 18px 22px;
    font-size: 0.93rem;
    line-height: 1.75;
    word-break: break-word;
}

.ai-message .bubble p {
    margin-bottom: 8px;
}

.ai-message .bubble p:last-of-type {
    margin-bottom: 0;
}

.ai-message .bubble strong {
    color: var(--gold-light);
    font-weight: 600;
}

.ai-message .bubble code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Fira Code', 'Consolas', monospace;
}

.ai-message .bubble ul,
.ai-message .bubble ol {
    margin: 8px 0;
    padding-left: 22px;
}

.ai-message .bubble li {
    margin-bottom: 4px;
}

/* RTL support for Urdu text */
.rtl {
    direction: rtl;
    text-align: right;
    font-family: var(--font-urdu), var(--font-sans);
}

/* ── References ── */
.references {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.references h4 {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ref-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    background: rgba(91, 141, 239, 0.08);
    border: 1px solid rgba(91, 141, 239, 0.18);
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ref-chip:hover {
    background: rgba(91, 141, 239, 0.16);
    border-color: var(--blue);
    box-shadow: 0 0 12px var(--blue-glow);
    transform: translateY(-1px);
}

.ref-chip .ref-page {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ── Copy button ── */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-light);
    background: rgba(255, 255, 255, 0.03);
}

.copy-btn.copied {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.25);
}

/* ── Typing indicator ── */
.typing-bubble {
    padding: 16px 22px !important;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 20px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Input area ── */
.input-area {
    flex-shrink: 0;
    padding: 16px 24px 12px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: var(--max-w);
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 18px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.input-wrapper:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow), 0 4px 20px rgba(0, 0, 0, 0.3);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.93rem;
    line-height: 1.5;
    padding: 10px 0;
    max-height: 120px;
    scrollbar-width: none;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-wrapper textarea::-webkit-scrollbar {
    display: none;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold), #b89a3e);
    color: #0b0d17;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px var(--gold-glow);
}

.send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 20px var(--gold-glow);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.disclaimer {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 8px;
    max-width: var(--max-w);
    margin-left: auto;
    margin-right: auto;
}

/* ── Custom scrollbar ── */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chat-area {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

/* ── Error message ── */
.error-text {
    color: var(--red);
}

/* ── Responsive: Tablets ── */
@media (max-width: 768px) {
    :root {
        --header-h: 56px;
    }

    header {
        padding: 0 16px;
    }

    .header-text h1 {
        font-size: 1.1rem;
    }

    .new-chat-btn span {
        display: none;
    }

    .new-chat-btn {
        padding: 8px 10px;
    }

    .welcome-screen {
        padding: 30px 16px 40px;
    }

    .welcome-icon {
        font-size: 44px;
    }

    .welcome-screen h2 {
        font-size: 1.4rem;
    }

    .suggestions {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .suggestion-card {
        padding: 12px;
    }

    .message {
        padding: 0 16px;
    }

    .user-message .bubble {
        max-width: 85%;
    }

    .ai-message .bubble {
        max-width: 88%;
    }

    .input-area {
        padding: 12px 16px 8px;
    }

    .input-wrapper {
        padding: 4px 4px 4px 14px;
    }
}

/* ── Responsive: Phones ── */
@media (max-width: 480px) {
    .suggestions {
        grid-template-columns: 1fr;
    }

    .welcome-sub {
        font-size: 0.85rem;
    }

    .status-badge {
        display: none;
    }

    .ai-message .avatar {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .ai-message .bubble {
        max-width: 90%;
        padding: 14px 16px;
    }

    .user-message .bubble {
        max-width: 90%;
        padding: 12px 16px;
    }

    .send-btn {
        width: 40px;
        height: 40px;
    }
}

/* ── Safe area for notched phones ── */
@supports (padding: max(0px)) {
    .input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}