/* =========================================================
   MIRADDH CHAT — STYLE.CSS
   Complete UI for:
   AI Chat / Writer / Image / Video / Templates /
   History / Saved Chats / Integrations / Dark Mode /
   New Chat / Clear Chat / Search / Voice / Attachments
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    height: 100%;
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background: #0f172a;
    color: #f8fafc;
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

a {
    text-decoration: none;
    color: inherit;
}

.hidden {
    display: none !important;
}

/* =========================================================
   APP
========================================================= */

.app {
    width: 100%;
    height: 100vh;

    display: flex;

    overflow: hidden;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 270px;
    min-width: 270px;
    height: 100vh;

    display: flex;
    flex-direction: column;

    padding: 16px 14px;

    background: #111827;
    border-right: 1px solid #263244;

    overflow: hidden;

    z-index: 100;
}

/* =========================================================
   BRAND
========================================================= */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 4px 6px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;

    font-size: 18px;
    font-weight: 700;
}

.brand-icon {
    width: 35px;
    height: 35px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: #2563eb;
    color: #fff;

    box-shadow: 0 8px 20px rgba(37, 99, 235, .25);
}

.sidebar-new-chat {
    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: transparent;
    color: #94a3b8;

    transition: .2s ease;
}

.sidebar-new-chat:hover {
    background: #1e293b;
    color: #fff;
}

/* =========================================================
   SEARCH
========================================================= */

.sidebar-search {
    height: 42px;

    display: flex;
    align-items: center;

    gap: 9px;

    padding: 0 12px;
    margin-bottom: 12px;

    border: 1px solid #293548;
    border-radius: 10px;

    background: #0f172a;
    color: #64748b;
}

.sidebar-search:focus-within {
    border-color: #3b82f6;
}

.sidebar-search input {
    width: 100%;

    border: 0;
    outline: 0;

    background: transparent;
    color: #e2e8f0;
}

.sidebar-search input::placeholder {
    color: #64748b;
}

/* =========================================================
   NEW CHAT
========================================================= */

.new-chat-btn {
    width: 100%;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 9px;

    border-radius: 10px;

    background: #2563eb;
    color: #fff;

    font-weight: 600;

    transition: .2s ease;
}

.new-chat-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(0);
}

/* =========================================================
   SIDEBAR NAV
========================================================= */

.sidebar-nav {
    flex: 1;

    margin-top: 18px;

    overflow-y: auto;

    padding-right: 3px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

.nav-title {
    padding: 12px 10px 7px;

    color: #64748b;

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav-item {
    min-height: 42px;

    display: flex;
    align-items: center;

    gap: 12px;

    padding: 0 12px;
    margin: 3px 0;

    border-radius: 9px;

    color: #94a3b8;

    font-size: 14px;

    transition: .2s ease;
}

.nav-item i {
    width: 18px;
    text-align: center;
}

.nav-item:hover {
    background: #1e293b;
    color: #f8fafc;
}

.nav-item.active {
    background: #1e3a5f;
    color: #fff;
}

/* =========================================================
   SIDEBAR BOTTOM
========================================================= */

.sidebar-bottom {
    padding-top: 12px;

    border-top: 1px solid #263244;
}

.sidebar-option {
    width: 100%;
    height: 42px;

    display: flex;
    align-items: center;

    gap: 12px;

    padding: 0 12px;
    margin-bottom: 7px;

    border-radius: 9px;

    background: transparent;
    color: #94a3b8;

    text-align: left;

    transition: .2s ease;
}

.sidebar-option:hover {
    background: #1e293b;
    color: #fff;
}

.user-profile {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 9px 7px;
}

.user-avatar {
    width: 36px;
    height: 36px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #334155;
    color: #fff;

    font-weight: 700;
}

.user-info {
    min-width: 0;
    flex: 1;

    display: flex;
    flex-direction: column;
}

.user-info strong {
    color: #e2e8f0;

    font-size: 13px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info small {
    margin-top: 2px;

    color: #64748b;
    font-size: 11px;
}

/* =========================================================
   MAIN CONTENT
========================================================= */

.main-content {
    min-width: 0;
    height: 100vh;

    flex: 1;

    display: flex;
    flex-direction: column;

    background: #0f172a;
}

/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    height: 64px;
    min-height: 64px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 22px;

    border-bottom: 1px solid #263244;

    background: rgba(15, 23, 42, .96);

    z-index: 50;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;

    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: transparent;
    color: #94a3b8;

    transition: .2s ease;
}

.icon-btn:hover {
    background: #1e293b;
    color: #fff;
}

.model-selector {
    display: flex;
    align-items: center;

    gap: 8px;

    padding: 9px 12px;

    border-radius: 9px;

    background: transparent;
    color: #e2e8f0;

    font-weight: 600;
}

.model-selector:hover {
    background: #1e293b;
}

.status-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: #22c55e;

    box-shadow: 0 0 8px #22c55e;
}

.mobile-brand {
    display: none;
}

/* =========================================================
   CHAT SECTION
========================================================= */

.chat-section {
    position: relative;

    flex: 1;
    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

/* =========================================================
   WELCOME
========================================================= */

.welcome-screen {
    width: min(850px, 92%);

    margin: auto;

    padding: 30px 0;

    text-align: center;
}

.welcome-icon {
    width: 62px;
    height: 62px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 0 auto 20px;

    border-radius: 18px;

    background: #2563eb;
    color: #fff;

    font-size: 31px;

    box-shadow: 0 12px 35px rgba(37, 99, 235, .25);
}

.welcome-screen h1 {
    margin-bottom: 10px;

    color: #f8fafc;

    font-size: clamp(25px, 4vw, 38px);
}

.welcome-screen > p {
    max-width: 620px;

    margin: auto;

    color: #94a3b8;

    line-height: 1.6;
}

/* =========================================================
   QUICK PROMPTS
========================================================= */

.quick-prompts {
    display: grid;

    grid-template-columns: repeat(4, 1fr);

    gap: 12px;

    margin-top: 30px;
}

.prompt-card {
    min-height: 105px;

    display: flex;
    flex-direction: column;

    align-items: flex-start;
    justify-content: center;

    gap: 12px;

    padding: 16px;

    border: 1px solid #293548;
    border-radius: 12px;

    background: #111827;
    color: #cbd5e1;

    text-align: left;

    transition: .2s ease;
}

.prompt-card:hover {
    border-color: #3b82f6;
    background: #172033;
    transform: translateY(-2px);
}

.prompt-card:active {
    transform: translateY(0);
}

.prompt-icon {
    font-size: 21px;
}

.prompt-card span:last-child {
    font-size: 13px;
    line-height: 1.4;
}

/* =========================================================
   CHAT BOX
========================================================= */

.chat-box {
    width: min(850px, 92%);

    flex: 1;

    margin: 0 auto;

    padding: 30px 0 25px;

    overflow-y: auto;

    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

/* =========================================================
   MESSAGE
========================================================= */

.message {
    width: 100%;

    display: flex;

    margin-bottom: 25px;

    animation: messageIn .2s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(7px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AI */

.message.ai {
    align-items: flex-start;
    gap: 12px;
}

.message.ai::before {
    content: "✦";

    width: 32px;
    height: 32px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: #2563eb;
    color: #fff;
}

/* USER */

.message.user {
    justify-content: flex-end;
}

.message.user p {
    max-width: 75%;

    padding: 11px 15px;

    border-radius: 16px 16px 4px 16px;

    background: #2563eb;
    color: #fff;

    line-height: 1.55;
}

/* AI TEXT */

.message.ai p {
    max-width: 80%;

    padding-top: 4px;

    color: #e2e8f0;

    line-height: 1.7;

    font-size: 15px;
}

/* =========================================================
   CODE
========================================================= */

.message pre {
    max-width: 100%;

    margin: 12px 0;

    padding: 15px;

    overflow-x: auto;

    border: 1px solid #334155;
    border-radius: 10px;

    background: #020617;

    text-align: left;
}

.message code {
    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 13px;
}

.message p > code {
    padding: 2px 6px;

    border-radius: 5px;

    background: #1e293b;
}

/* =========================================================
   COPY RESPONSE
========================================================= */

.copy-response-btn {
    margin-top: 8px;

    padding: 7px 10px;

    border: 1px solid #334155;
    border-radius: 7px;

    background: #111827;
    color: #94a3b8;

    font-size: 11px;

    transition: .2s ease;
}

.copy-response-btn:hover {
    background: #1e293b;
    color: #fff;
}

/* =========================================================
   TYPING
========================================================= */

.typing-container {
    width: min(850px, 92%);

    display: flex;
    align-items: center;

    gap: 12px;

    margin: 0 auto 12px;
}

.typing-container[hidden] {
    display: none;
}

.ai-avatar {
    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: #2563eb;
    color: #fff;
}

.typing-bubble {
    display: flex;
    align-items: center;

    gap: 5px;

    padding: 12px 15px;

    border-radius: 13px;

    background: #1e293b;
}

.typing-bubble span {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: #94a3b8;

    animation: typing 1.2s infinite;
}

.typing-bubble span:nth-child(2) {
    animation-delay: .15s;
}

.typing-bubble span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: .35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* =========================================================
   COMPOSER
========================================================= */

.composer-wrapper {
    width: min(850px, 92%);

    margin: 0 auto;

    padding: 8px 0 18px;
}

.composer {
    min-height: 58px;

    display: flex;
    align-items: flex-end;

    gap: 8px;

    padding: 8px;

    border: 1px solid #334155;
    border-radius: 16px;

    background: #111827;

    box-shadow: 0 10px 30px rgba(0,0,0,.2);

    transition: .2s ease;
}

.composer:focus-within {
    border-color: #475569;
}

.composer-btn {
    width: 40px;
    height: 40px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: transparent;
    color: #94a3b8;

    transition: .2s ease;
}

.composer-btn:hover {
    background: #1e293b;
    color: #fff;
}

.composer-btn.active {
    background: #1e3a5f;
    color: #60a5fa;
}

.message-input {
    min-height: 40px;
    max-height: 180px;

    flex: 1;

    resize: none;

    padding: 9px 4px;

    border: 0;
    outline: 0;

    background: transparent;
    color: #f8fafc;

    line-height: 1.5;

    overflow-y: auto;
}

.message-input::placeholder {
    color: #64748b;
}

.send-btn {
    width: 40px;
    height: 40px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: #2563eb;
    color: #fff;

    transition: .2s ease;
}

.send-btn:hover {
    background: #1d4ed8;
}

.send-btn:disabled {
    opacity: .45;
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 8px 5px 0;

    color: #64748b;

    font-size: 11px;
}

kbd {
    padding: 2px 5px;

    border: 1px solid #334155;
    border-radius: 4px;

    background: #111827;
    color: #94a3b8;

    font-size: 10px;
}

/* =========================================================
   IMAGE / VIDEO / WRITER / TEMPLATE PANELS
========================================================= */

.feature-panel {
    width: min(900px, 92%);

    margin: auto;

    padding: 25px;

    border: 1px solid #293548;
    border-radius: 16px;

    background: #111827;

    box-shadow: 0 15px 45px rgba(0,0,0,.2);
}

.feature-panel h2 {
    margin-bottom: 8px;

    color: #f8fafc;
}

.feature-panel p {
    color: #94a3b8;

    line-height: 1.6;
}

.feature-grid {
    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 14px;

    margin-top: 20px;
}

.feature-card {
    padding: 18px;

    border: 1px solid #293548;
    border-radius: 12px;

    background: #0f172a;
    color: #e2e8f0;

    transition: .2s ease;
}

.feature-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.feature-card i {
    margin-bottom: 10px;

    color: #60a5fa;

    font-size: 22px;
}

.feature-card h3 {
    margin-bottom: 6px;
}

.feature-card p {
    font-size: 13px;
}

/* =========================================================
   IMAGE PREVIEW
========================================================= */

.image-result {
    width: 100%;

    margin-top: 15px;

    border: 1px solid #334155;
    border-radius: 12px;

    overflow: hidden;

    background: #020617;
}

.image-result img {
    display: block;

    width: 100%;
    max-height: 600px;

    object-fit: contain;
}

.image-actions {
    display: flex;

    gap: 8px;

    padding: 10px;
}

.image-actions button {
    padding: 8px 12px;

    border-radius: 8px;

    background: #1e293b;
    color: #e2e8f0;
}

.image-actions button:hover {
    background: #334155;
}

/* =========================================================
   VIDEO
========================================================= */

.video-result {
    width: 100%;

    margin-top: 15px;

    border: 1px solid #334155;
    border-radius: 12px;

    overflow: hidden;

    background: #020617;
}

.video-result video {
    display: block;

    width: 100%;
    max-height: 600px;
}

/* =========================================================
   HISTORY / SAVED
========================================================= */

.history-list,
.saved-list {
    display: flex;
    flex-direction: column;

    gap: 8px;

    margin-top: 18px;
}

.history-item,
.saved-item {
    padding: 13px 15px;

    border: 1px solid #293548;
    border-radius: 10px;

    background: #0f172a;

    color: #cbd5e1;

    transition: .2s ease;
}

.history-item:hover,
.saved-item:hover {
    border-color: #3b82f6;
    background: #172033;
}

/* =========================================================
   MODAL
========================================================= */

.modal-overlay {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(2,6,23,.75);

    backdrop-filter: blur(5px);
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    position: relative;

    width: min(560px, 100%);

    max-height: 85vh;

    overflow-y: auto;

    padding: 28px;

    border: 1px solid #334155;
    border-radius: 16px;

    background: #111827;

    box-shadow: 0 25px 80px rgba(0,0,0,.5);
}

.modal-close {
    position: absolute;

    top: 12px;
    right: 12px;

    width: 34px;
    height: 34px;

    border-radius: 8px;

    background: transparent;
    color: #94a3b8;
}

.modal-close:hover {
    background: #1e293b;
    color: #fff;
}

.modal h2 {
    margin-bottom: 12px;
}

.modal input,
.modal textarea,
.modal select {
    width: 100%;

    padding: 11px 12px;

    margin-top: 8px;

    border: 1px solid #334155;
    border-radius: 9px;

    outline: 0;

    background: #0f172a;
    color: #f8fafc;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus {
    border-color: #3b82f6;
}

/* =========================================================
   LIGHT MODE
========================================================= */

body.light-mode {
    background: #f8fafc;
    color: #0f172a;
}

body.light-mode .sidebar,
body.light-mode .main-content,
body.light-mode .chat-section {
    background: #f8fafc;
}

body.light-mode .sidebar {
    border-color: #e2e8f0;
}

body.light-mode .topbar {
    background: rgba(255,255,255,.96);
    border-color: #e2e8f0;
}

body.light-mode .sidebar-search,
body.light-mode .composer,
body.light-mode .prompt-card,
body.light-mode .feature-panel,
body.light-mode .modal {
    background: #fff;
    border-color: #e2e8f0;
}

body.light-mode .sidebar-search input,
body.light-mode .message-input {
    color: #0f172a;
}

body.light-mode .welcome-screen h1 {
    color: #0f172a;
}

body.light-mode .welcome-screen > p,
body.light-mode .message.ai p {
    color: #475569;
}

body.light-mode .typing-bubble {
    background: #e2e8f0;
}

body.light-mode .feature-card,
body.light-mode .history-item,
body.light-mode .saved-item {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.light-mode .modal input,
body.light-mode .modal textarea,
body.light-mode .modal select {
    background: #fff;
    color: #0f172a;
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 900px) {

    .sidebar {
        width: 230px;
        min-width: 230px;
    }

    .quick-prompts {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {

    body {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;

        top: 0;
        left: -280px;

        width: 270px;
        min-width: 270px;

        transition: left .25s ease;

        box-shadow: 10px 0 40px rgba(0,0,0,.35);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .mobile-brand {
        display: flex;
        align-items: center;

        gap: 10px;
    }

    .topbar-left {
        display: flex;
    }

    .model-selector {
        display: none;
    }

    .topbar {
        padding: 0 12px;
    }

    .welcome-screen {
        padding: 20px 0;
    }

    .welcome-screen h1 {
        font-size: 26px;
    }

    .quick-prompts {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .prompt-card {
        min-height: 90px;
        padding: 12px;
    }

    .message.user p {
        max-width: 85%;
    }

    .message.ai p {
        max-width: calc(100% - 42px);
    }

    .composer-wrapper,
    .chat-box,
    .typing-container {
        width: 94%;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {

    .topbar {
        height: 58px;
        min-height: 58px;
    }

    .topbar-right {
        gap: 2px;
    }

    .topbar-right .icon-btn {
        width: 34px;
        height: 34px;
    }

    .welcome-icon {
        width: 54px;
        height: 54px;
        font-size: 27px;
    }

    .welcome-screen h1 {
        font-size: 23px;
    }

    .welcome-screen > p {
        font-size: 13px;
    }

    .quick-prompts {
        grid-template-columns: 1fr;
    }

    .prompt-card {
        min-height: 55px;

        flex-direction: row;
        align-items: center;
    }

    .composer-footer {
        font-size: 9px;
    }

    .composer-footer span:last-child {
        display: none;
    }

    .composer-btn {
        width: 36px;
        height: 36px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
    }
}