
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --green: #27834d;
    --green-dark: #17683a;
    --green-light: #e9f5ec;
    --bg: #f5f8f5;
    --card: #ffffff;
    --text: #203328;
    --muted: #78877d;
    --border: #e5ece6;
    --shadow: 0 8px 30px rgba(25,70,42,.06);
}

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

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

button, input, textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* القائمة الجانبية */

.sidebar {
    width: 260px;
    background: var(--card);
    border-left: 1px solid var(--border);
    padding: 25px 17px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 100vh;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 30px;
}

.brand-logo {
    width: 43px;
    height: 43px;
    border-radius: 14px;
    background: var(--green);
    color: white;
    display: grid;
    place-items: center;
    font-size: 25px;
    font-weight: 800;
}

.brand h2 {
    font-size: 21px;
    line-height: 1.3;
}

.brand span {
    font-size: 10px;
    color: var(--muted);
}

.close-sidebar {
    display: none;
    margin-right: auto;
    border: 0;
    background: transparent;
    font-size: 25px;
    color: var(--muted);
}

.new-chat {
    background: var(--green);
    color: white;
    border: 0;
    border-radius: 11px;
    padding: 12px;
    font-weight: 700;
}

.new-chat:hover, .primary-btn:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
}

.side-label {
    color: var(--muted);
    font-size: 12px;
    margin: 27px 8px 12px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #607166;
    text-align: right;
    font-size: 14px;
}

.nav-item:hover, .nav-item.active {
    background: var(--green-light);
    color: var(--green-dark);
    font-weight: 700;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    border: 0;
    background: transparent;
    text-align: right;
    padding: 9px;
    border-radius: 8px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.history-item:hover {
    background: var(--bg);
    color: var(--green);
}

.sidebar-bottom {
    margin-top: auto;
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 5px 0;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.avatar {
    width: 37px;
    height: 37px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green);
    font-weight: 800;
}

.profile strong, .profile small {
    display: block;
}

.profile strong {
    font-size: 12px;
}

.profile small {
    color: var(--muted);
    font-size: 10px;
}

/* المحتوى */

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 75px;
    padding: 0 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    font-size: 13px;
    color: var(--muted);
}

.breadcrumb span {
    color: var(--green);
    font-weight: 700;
}

.top-actions button, .menu-btn {
    border: 0;
    background: var(--green-light);
    color: var(--green-dark);
    width: 39px;
    height: 39px;
    border-radius: 11px;
    font-size: 19px;
}

.menu-btn {
    display: none;
}

.page {
    display: none;
    max-width: 1120px;
    margin: auto;
    padding: 42px 5%;
}

.page.active {
    display: block;
}

.welcome {
    margin-bottom: 28px;
}

.welcome-tag {
    display: inline-block;
    background: var(--green-light);
    color: var(--green-dark);
    padding: 6px 13px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
}

.welcome h1, .page-heading h1 {
    font-size: clamp(25px,4vw,35px);
    margin: 13px 0 5px;
}

.welcome h1 span {
    color: var(--green);
}

.welcome p, .page-heading p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.9;
}

.page-heading {
    margin-bottom: 28px;
}

/* الرئيسية */

.hero-card {
    background: linear-gradient(115deg,#155f36,#32945a);
    color: white;
    border-radius: 22px;
    padding: 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 235px;
    overflow: hidden;
    margin-bottom: 35px;
}

.hero-content {
    max-width: 580px;
}

.hero-content > span {
    font-size: 12px;
    color: #d4f4dc;
}

.hero-content h2 {
    font-size: clamp(22px,3vw,29px);
    margin: 10px 0;
}

.hero-content p {
    color: #e2f4e7;
    font-size: 13px;
    line-height: 1.9;
    margin-bottom: 17px;
}

.hero-plant {
    font-size: 110px;
    opacity: .9;
    transform: rotate(-12deg);
    padding: 0 20px;
}

.primary-btn {
    background: var(--green);
    color: white;
    border: 0;
    border-radius: 10px;
    padding: 11px 19px;
    font-weight: 700;
    transition: .2s;
}

.hero-card .primary-btn {
    background: white;
    color: var(--green-dark);
}

.section-title {
    font-size: 19px;
    margin-bottom: 17px;
}

.tools-grid, .care-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 15px;
}

.tool-card, .care-card, .plant-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.tool-card {
    cursor: pointer;
    transition: .2s;
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: #a8d6b6;
}

.tool-icon {
    width: 43px;
    height: 43px;
    border-radius: 12px;
    background: var(--green-light);
    display: grid;
    place-items: center;
    color: var(--green);
    font-size: 22px;
    margin-bottom: 13px;
}

.tool-card h3, .care-card h3, .plant-card h3 {
    font-size: 15px;
    margin-bottom: 7px;
}

.tool-card p, .care-card p, .plant-card p {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.9;
}

.tool-card > span {
    display: inline-block;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    margin-top: 13px;
}

.bottom-note {
    margin-top: 25px;
    display: flex;
    gap: 13px;
    align-items: center;
    padding: 17px;
    background: var(--green-light);
    border-radius: 13px;
}

.bottom-note > span {
    font-size: 25px;
}

.bottom-note strong {
    font-size: 13px;
}

.bottom-note p {
    color: var(--muted);
    font-size: 11px;
}

/* الشات */

.chat-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    min-height: 490px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    min-height: 350px;
    max-height: 530px;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 90%;
}

.message-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--green-light);
}

.message-content {
    background: var(--bg);
    border-radius: 0 13px 13px 13px;
    padding: 12px 15px;
    min-width: 0;
}

.message-content strong {
    font-size: 12px;
    color: var(--green);
}

.message-content p {
    font-size: 13px;
    line-height: 1.9;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-top: 5px;
}

.user-message {
    align-self: flex-start;
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--green);
    color: white;
    border-radius: 13px 0 13px 13px;
}

.user-message .message-content strong {
    color: #e2f4e7;
}

.chat-input-area {
    margin: 0 20px;
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--bg);
}

.chat-input-area textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 8px;
    color: var(--text);
    max-height: 130px;
}

.send-btn {
    width: 39px;
    height: 39px;
    border: 0;
    border-radius: 10px;
    background: var(--green);
    color: white;
    font-size: 19px;
}

.chat-disclaimer {
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    padding: 12px;
}

.typing {
    color: var(--muted);
    font-size: 12px;
    padding: 5px 10px;
}

/* التشخيص */

.diagnose-card, .settings-card {
    background: var(--card);
    padding: 25px;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.upload-box {
    display: block;
    text-align: center;
    border: 2px dashed #b7d8c0;
    border-radius: 16px;
    padding: 40px 15px;
    background: var(--bg);
    cursor: pointer;
    transition: .2s;
}

.upload-box:hover {
    background: var(--green-light);
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.upload-box h3 {
    font-size: 17px;
}

.upload-box p, .upload-box span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 7px;
}

.image-preview {
    display: none;
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    margin: 20px auto;
    border-radius: 13px;
}

.diagnose-btn {
    display: block;
    margin: 20px auto 0;
}

.diagnose-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.result-box {
    display: none;
    white-space: pre-wrap;
    line-height: 2;
    background: var(--green-light);
    color: var(--text);
    border-radius: 12px;
    padding: 18px;
    margin-top: 20px;
    font-size: 13px;
}

/* البحث والنباتات */

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
}

.search-box input, .settings-card input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    outline: none;
}

.search-box input:focus, .settings-card input:focus {
    border-color: var(--green);
}

.search-box button {
    border: 0;
    background: var(--green);
    color: white;
    border-radius: 10px;
    padding: 0 20px;
}

.plant-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 15px;
}

.plant-emoji {
    font-size: 43px;
    margin-bottom: 12px;
}

.care-card > span {
    font-size: 33px;
    display: inline-block;
    margin-bottom: 12px;
}

/* الإعدادات */

.settings-card {
    max-width: 550px;
}

.settings-card label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.settings-card input {
    width: 100%;
    margin-bottom: 13px;
}

.settings-card hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 23px 0;
}

.secondary-btn {
    background: transparent;
    border: 1px solid #d88c8c;
    color: #b53f3f;
    border-radius: 10px;
    padding: 10px 15px;
}

/* الوضع الليلي */

body.dark {
    --bg: #111b15;
    --card: #1b2920;
    --text: #edf5ee;
    --muted: #a2b2a6;
    --border: #2b3c30;
    --green-light: #263d2d;
    --shadow: 0 8px 30px rgba(0,0,0,.12);
}

body.dark .nav-item {
    color: #c1cec4;
}

body.dark .nav-item.active {
    color: #a6e2b6;
}

body.dark .message-content {
    background: #25342a;
}

body.dark .user-message .message-content {
    background: var(--green);
}

body.dark .upload-box {
    border-color: #496c52;
}

/* الموبايل */

.mobile-overlay {
    display: none;
}

@media (max-width: 1000px) {
    .tools-grid, .plant-grid, .care-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }
}

@media (max-width: 700px) {
    .sidebar {
        position: fixed;
        right: -280px;
        top: 0;
        height: 100%;
        min-height: 100%;
        width: 270px;
        transition: .25s;
        overflow-y: auto;
    }

    .sidebar.open {
        right: 0;
    }

    .close-sidebar, .menu-btn {
        display: grid;
        place-items: center;
    }

    .mobile-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 15;
    }

    .topbar {
        height: 65px;
        padding: 0 17px;
    }

    .page {
        padding: 27px 17px;
    }

    .hero-card {
        padding: 23px;
    }

    .hero-plant {
        font-size: 65px;
        padding: 0;
    }

    .tools-grid, .plant-grid, .care-grid {
        gap: 10px;
    }

    .tool-card, .plant-card, .care-card {
        padding: 14px;
    }

    .chat-messages {
        padding: 15px;
    }

    .chat-container {
        min-height: 450px;
    }

    .message {
        max-width: 100%;
    }
}

@media (max-width: 390px) {
    .hero-plant {
        display: none;
    }

    .tools-grid, .plant-grid, .care-grid {
        grid-template-columns: 1fr;
    }
}
