/* =========================================================================
   CodeMind Theme
   كحلي احترافي + برتقالي متوسط
   تصميم مريح للعين ومناسب لمنصة كودينج
   ========================================================================= */

:root {
    --bg-main: #0b1220;
    --bg-sidebar: #101b2d;
    --bg-panel: #13223a;
    --bg-soft: #182a45;

    --accent-orange: #f28c28;
    --accent-orange-hover: #ff9f3f;
    --accent-orange-soft: rgba(242, 140, 40, 0.16);
    --accent-orange-border: rgba(242, 140, 40, 0.38);

    --text-main: #f8fafc;
    --text-muted: #a8b3c7;
    --text-soft: #d7deea;

    --border-soft: rgba(255, 255, 255, 0.08);
    --shadow-soft: rgba(0, 0, 0, 0.22);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background:
        radial-gradient(circle at top right, rgba(242, 140, 40, 0.08), transparent 32%),
        linear-gradient(135deg, #08111f 0%, #0b1220 55%, #101b2d 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* =========================================================================
   الحاوية الأساسية
   ========================================================================= */

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
    width: 310px;
    background: rgba(16, 27, 45, 0.96);
    border-left: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
    box-shadow: -12px 0 35px rgba(0, 0, 0, 0.18);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-soft);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    background: linear-gradient(135deg, var(--accent-orange), #ffc26b);
    box-shadow: 0 10px 24px rgba(242, 140, 40, 0.25);
    font-size: 22px;
}

.logo h2 {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
}

.new-chat-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-orange), #e67a18);
    border: none;
    color: #111827;
    padding: 13px 14px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.25s ease;
    box-shadow: 0 12px 24px rgba(242, 140, 40, 0.22);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, var(--accent-orange-hover), var(--accent-orange));
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(242, 140, 40, 0.30);
}

/* =========================================================================
   قائمة الشاتات
   ========================================================================= */

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chats-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 5px;
}

.chats-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(242, 140, 40, 0.35);
    border-radius: 999px;
}

.chat-item {
    padding: 12px 13px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: 0.22s ease;
    background: transparent;
    border: 1px solid transparent;
    font-size: 13.5px;
    color: var(--text-soft);
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(242, 140, 40, 0.20);
}

.chat-item.active {
    background: linear-gradient(135deg, rgba(242, 140, 40, 0.16), rgba(255, 255, 255, 0.035));
    border-color: var(--accent-orange-border);
    color: var(--text-main);
    font-weight: 700;
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-delete-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.2s ease;
    flex-shrink: 0;
}

.chat-item:hover .chat-delete-btn,
.chat-item.active .chat-delete-btn {
    opacity: 1;
}

.chat-delete-btn:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* =========================================================================
   Footer Sidebar
   ========================================================================= */

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-soft);
}

.reset-all-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    padding: 11px;
    cursor: pointer;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    transition: 0.22s ease;
}

.reset-all-btn:hover {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: rgba(239, 68, 68, 0.25);
}

/* =========================================================================
   Main Chat
   ========================================================================= */

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background:
        radial-gradient(circle at top left, rgba(242, 140, 40, 0.055), transparent 34%),
        rgba(11, 18, 32, 0.88);
    position: relative;
}

.chat-header {
    height: 76px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
    background: rgba(16, 27, 45, 0.82);
    backdrop-filter: blur(14px);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right h3,
#currentChatTitle {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
}

.toggle-sidebar-btn {
    display: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-soft);
    cursor: pointer;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar-btn:hover {
    border-color: var(--accent-orange-border);
    color: var(--accent-orange);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-soft);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.22s ease;
}

.action-btn:hover {
    color: var(--accent-orange);
    border-color: var(--accent-orange-border);
    background: var(--accent-orange-soft);
}

/* =========================================================================
   Messages
   ========================================================================= */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px 26px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageFade 0.22s ease-out;
}

.message.user {
    align-self: flex-start;
}

.message.bot {
    align-self: flex-end;
}

.message-bubble {
    padding: 15px 19px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.8;
    word-break: break-word;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--accent-orange), #d97706);
    color: #111827;
    border-top-right-radius: 5px;
    font-weight: 700;
}

.message.bot .message-bubble {
    background: rgba(19, 34, 58, 0.94);
    color: var(--text-main);
    border: 1px solid var(--border-soft);
    border-top-left-radius: 5px;
    border-right: 4px solid var(--accent-orange);
}

.message-time {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

.message.user .message-time {
    align-self: flex-start;
}

.message.bot .message-time {
    align-self: flex-end;
}

/* =========================================================================
   Typing Indicator
   ========================================================================= */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 64px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-orange);
    border-radius: 50%;
    animation: typingBounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

/* =========================================================================
   Input
   ========================================================================= */

.input-container {
    padding: 24px 26px;
    background: rgba(16, 27, 45, 0.92);
    border-top: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 920px;
    margin: 0 auto;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: rgba(8, 17, 31, 0.95);
    transition: 0.25s ease;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.input-wrapper:focus-within {
    border-color: var(--accent-orange-border);
    box-shadow: 0 0 0 4px rgba(242, 140, 40, 0.10);
}

.input-wrapper input {
    width: 100%;
    padding: 17px 18px;
    padding-left: 68px;
    border: none;
    outline: none;
    font-size: 14.5px;
    background: transparent;
    color: var(--text-main);
}

.input-wrapper input::placeholder {
    color: rgba(168, 179, 199, 0.75);
}

.send-btn {
    position: absolute;
    left: 10px;
    background: linear-gradient(135deg, var(--accent-orange), #d97706);
    color: #111827;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.22s ease;
    box-shadow: 0 8px 18px rgba(242, 140, 40, 0.24);
}

.send-btn:hover {
    background: linear-gradient(135deg, var(--accent-orange-hover), var(--accent-orange));
    transform: translateY(-1px);
}

.footer-note {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* =========================================================================
   Code Blocks
   ========================================================================= */

.code-box {
    margin-top: 12px;
    border-radius: 14px;
    overflow: hidden;
    background: #07111f;
    border: 1px solid rgba(242, 140, 40, 0.18);
    direction: ltr;
    text-align: left;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f1b2e;
    color: #f8fafc;
    padding: 10px 14px;
    font-size: 13px;
    direction: ltr;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.code-header button {
    border: none;
    background: var(--accent-orange);
    color: #111827;
    padding: 6px 12px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.code-header button:hover {
    background: var(--accent-orange-hover);
}

.code-box pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-box code {
    color: #e5e7eb;
    font-family: Consolas, Monaco, monospace;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre;
}

.run-note {
    margin-top: 10px;
    color: var(--text-muted);
    line-height: 1.8;
}

/* =========================================================================
   Mobile
   ========================================================================= */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(8, 17, 31, 0.74);
    backdrop-filter: blur(4px);
    z-index: 5;
}

@media (max-width: 768px) {
    .toggle-sidebar-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        right: -310px;
        top: 0;
        bottom: 0;
    }

    .sidebar.open {
        right: 0;
        box-shadow: -14px 0 35px rgba(0, 0, 0, 0.35);
    }

    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }

    .chat-header {
        padding: 0 16px;
    }

    .messages-container {
        padding: 24px 16px;
    }

    .message {
        max-width: 92%;
    }

    .input-container {
        padding: 18px 14px;
    }

    .footer-note {
        font-size: 10.5px;
    }
}

/* =========================================================================
   Animations
   ========================================================================= */

@keyframes messageFade {
    from {
        opacity: 0;
        transform: translateY(7px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}


/* =========================================================================
   Auth Pages - Login / Register
   Light Theme - كحلي + برتقالي
   ========================================================================= */

.auth-page {
    min-height: 100vh;
    overflow: auto;
    background:
        radial-gradient(circle at top right, rgba(242, 140, 40, 0.18), transparent 32%),
        radial-gradient(circle at bottom left, rgba(11, 18, 32, 0.08), transparent 34%),
        linear-gradient(135deg, #f8fafc 0%, #eef4fb 52%, #e8eef7 100%);
    color: #0f172a;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 28px;
    padding: 36px 30px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.13);
    backdrop-filter: blur(14px);
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f28c28;
    background: linear-gradient(135deg, #0b1220, #13223a);
    box-shadow: 0 14px 30px rgba(11, 18, 32, 0.22);
    font-size: 30px;
}

.auth-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: #0b1220;
    margin-bottom: 7px;
}

.auth-logo p {
    color: #64748b;
    font-size: 14px;
    line-height: 1.8;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 13px;
    color: #1e293b;
    font-weight: 800;
}

.form-group input,
.form-group select {
    width: 100%;
    height: 48px;
    border: 1px solid #d7dee9;
    outline: none;
    border-radius: 14px;
    background: #ffffff;
    color: #0f172a;
    padding: 0 14px;
    font-size: 14px;
    transition: 0.25s ease;
}

.form-group input::placeholder {
    color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #f28c28;
    box-shadow: 0 0 0 4px rgba(242, 140, 40, 0.14);
}

.auth-message {
    min-height: 22px;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
    font-weight: 700;
}

.auth-message.error {
    color: #dc2626;
}

.auth-message.success {
    color: #16a34a;
}

.auth-btn {
    height: 52px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #f28c28, #d97706);
    color: #111827;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    transition: 0.25s ease;
    box-shadow: 0 14px 28px rgba(242, 140, 40, 0.26);
}

.auth-btn:hover {
    background: linear-gradient(135deg, #ff9f3f, #f28c28);
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(242, 140, 40, 0.32);
}

.auth-switch {
    margin-top: 22px;
    text-align: center;
    color: #64748b;
    font-size: 13.5px;
}

.auth-switch a {
    color: #d97706;
    font-weight: 900;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.logout-btn {
    width: auto;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 800;
}

/* Mobile */
@media (max-width: 600px) {
    .auth-container {
        padding: 18px;
    }

    .auth-card {
        padding: 30px 22px;
        border-radius: 24px;
    }

    .auth-logo h1 {
        font-size: 24px;
    }

    .auth-logo p {
        font-size: 13px;
    }
}



.logo-subtitle {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.chat-title-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-title-box span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-user-box {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--border-soft);
    text-decoration: none;
    color: var(--text-main);
    transition: 0.22s ease;
}

.sidebar-user-box:hover {
    background: var(--accent-orange-soft);
    border-color: var(--accent-orange-border);
    transform: translateY(-1px);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent-orange), #ffc26b);
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 17px;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info strong {
    display: block;
    font-size: 13.5px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-arrow {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}