/* =========================================================
   ETHMAR - إثمار الاستثماري 🌿
   Unified Mobile & Desktop App Design System
   Exact replication of the Kotlin/Compose Native App UI
   ========================================================= */

:root {
    /* Ethmar Color Tokens from Theme.kt / Color.kt */
    --ethmar-primary: #6750A4;
    --ethmar-on-primary: #FFFFFF;
    --ethmar-primary-container: #EADDFF;
    --ethmar-on-primary-container: #21005D;

    --ethmar-secondary: #006A6A;
    --ethmar-on-secondary: #FFFFFF;
    --ethmar-secondary-container: #F3EDF7;
    --ethmar-on-secondary-container: #1D1B20;

    --ethmar-bg: #FEF7FF;
    --ethmar-on-bg: #1D1B20;
    --ethmar-surface: #FEF7FF;
    --ethmar-surface-variant: #E7E0EC;
    --ethmar-on-surface: #1D1B20;
    --ethmar-on-surface-variant: #49454F;
    --ethmar-outline: #CAC4D0;

    --ethmar-emerald: #10B981;
    --ethmar-gold: #F59E0B;
    --ethmar-danger: #B3261E;

    --ethmar-card-shadow: 0 4px 16px rgba(103, 80, 164, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    --ethmar-card-radius: 20px;
}

/* Dark mode overrides when user switches theme */
body.fintech-theme {
    --ethmar-bg: #0B0E17;
    --ethmar-on-bg: #F8FAFC;
    --ethmar-surface: #111827;
    --ethmar-surface-variant: #1F2937;
    --ethmar-on-surface: #F8FAFC;
    --ethmar-on-surface-variant: #94A3B8;
    --ethmar-outline: rgba(255, 255, 255, 0.12);
    --ethmar-secondary-container: #1E293B;
    --ethmar-on-secondary-container: #F8FAFC;
    --ethmar-primary-container: rgba(103, 80, 164, 0.25);
    --ethmar-on-primary-container: #D0BCFF;
}

body.ethmar-body {
    background-color: var(--ethmar-bg);
    color: var(--ethmar-on-bg);
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* App Shell Layout */
.ethmar-app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 600px; /* Mobile first preview container centered on desktop */
    margin: 0 auto;
    background: var(--ethmar-surface);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.08);
    position: relative;
    padding-bottom: 84px; /* Space for bottom nav bar */
}

@media (min-width: 1024px) {
    .ethmar-app-shell {
        max-width: 1100px;
        box-shadow: 0 0 80px rgba(103, 80, 164, 0.12);
    }
}

/* =========================================================
   TOP APP BAR (CenterAlignedTopAppBar in Compose)
   ========================================================= */
.ethmar-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--ethmar-secondary-container);
    border-bottom: 1px solid var(--ethmar-outline);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s ease;
}

.ethmar-role-badge {
    background: var(--ethmar-primary-container);
    color: var(--ethmar-on-primary-container);
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ethmar-topbar-brand {
    font-size: 17px;
    font-weight: 900;
    color: var(--ethmar-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    letter-spacing: -0.3px;
}

.ethmar-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ethmar-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ethmar-primary);
    font-size: 18px;
    position: relative;
    transition: background 0.2s ease;
}

.ethmar-icon-btn:hover {
    background: rgba(103, 80, 164, 0.12);
}

.ethmar-unread-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--ethmar-danger);
    color: #FFF;
    font-size: 9px;
    font-weight: 900;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ethmar-surface);
}

/* =========================================================
   BOTTOM NAVIGATION BAR (NavigationBar in Compose)
   ========================================================= */
.ethmar-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: var(--ethmar-secondary-container);
    border-top: 1px solid var(--ethmar-outline);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 4px env(safe-area-inset-bottom, 8px) 4px;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    .ethmar-bottom-nav {
        max-width: 1100px;
    }
}

.ethmar-nav-item {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    flex: 1;
    padding: 6px 2px;
    border-radius: 16px;
    color: var(--ethmar-on-surface-variant);
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ethmar-nav-pill {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.ethmar-nav-item.active .ethmar-nav-pill {
    background: var(--ethmar-primary-container);
    color: var(--ethmar-on-primary-container);
    transform: scale(1.08);
}

.ethmar-nav-item span.ethmar-nav-label {
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
}

.ethmar-nav-item.active span.ethmar-nav-label {
    color: var(--ethmar-on-primary-container);
    font-weight: 800;
}

/* =========================================================
   SCREEN VIEWS CONTAINER & TABS
   ========================================================= */
.ethmar-screens-container {
    padding: 16px;
}

.ethmar-screen {
    display: none;
    animation: ethmarFadeIn 0.25s ease-out;
}

.ethmar-screen.active {
    display: block;
}

@keyframes ethmarFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   CARDS & MATERIAL 3 STYLES
   ========================================================= */
.ethmar-card {
    background: var(--ethmar-surface);
    border: 1px solid var(--ethmar-outline);
    border-radius: var(--ethmar-card-radius);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--ethmar-card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ethmar-card--hero {
    background: linear-gradient(135deg, #21005D 0%, #6750A4 100%);
    color: #FFFFFF;
    border: none;
    box-shadow: 0 10px 30px rgba(103, 80, 164, 0.35);
}

.ethmar-card--hero .ethmar-label {
    color: rgba(255, 255, 255, 0.85);
}

.ethmar-card--hero .ethmar-amount {
    color: #FFFFFF;
}

.ethmar-card--teal {
    background: linear-gradient(135deg, #004D40 0%, #006A6A 100%);
    color: #FFFFFF;
    border: none;
}

/* KPI Stats Rows */
.ethmar-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 768px) {
    .ethmar-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.ethmar-stat-pill {
    background: var(--ethmar-secondary-container);
    border-radius: 16px;
    padding: 14px 12px;
    text-align: center;
    border: 1px solid var(--ethmar-outline);
}

.ethmar-stat-pill .ethmar-stat-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--ethmar-on-surface-variant);
    margin-bottom: 4px;
}

.ethmar-stat-pill .ethmar-stat-val {
    font-size: 18px;
    font-weight: 900;
    color: var(--ethmar-primary);
}

/* Quick Action Chips */
.ethmar-actions-row {
    display: flex;
    gap: 10px;
    margin: 14px 0 20px 0;
    overflow-x: auto;
    padding-bottom: 4px;
}

.ethmar-action-btn {
    flex: 1;
    background: var(--ethmar-primary);
    color: var(--ethmar-on-primary);
    border: none;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.3);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.ethmar-action-btn:hover {
    background: #7965B2;
    transform: translateY(-2px);
}

.ethmar-action-btn--secondary {
    background: var(--ethmar-primary-container);
    color: var(--ethmar-on-primary-container);
    box-shadow: none;
}

.ethmar-action-btn--secondary:hover {
    background: #DCC9FA;
}

/* Project Cards */
.ethmar-project-card {
    background: var(--ethmar-surface);
    border: 1px solid var(--ethmar-outline);
    border-radius: var(--ethmar-card-radius);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--ethmar-card-shadow);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.ethmar-project-card:hover {
    border-color: var(--ethmar-primary);
    transform: translateY(-2px);
}

.ethmar-project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.ethmar-project-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--ethmar-on-surface);
    margin: 0 0 4px 0;
}

.ethmar-project-owner {
    font-size: 12px;
    color: var(--ethmar-on-surface-variant);
}

.ethmar-return-tag {
    background: #E8F5E9;
    color: #2E7D32;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

/* Progress bar */
.ethmar-progress-wrap {
    background: var(--ethmar-surface-variant);
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    margin: 10px 0;
}

.ethmar-progress-bar {
    background: linear-gradient(90deg, #6750A4 0%, #006A6A 100%);
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* =========================================================
   SMART NOTIFICATION PANEL (DRAWER)
   ========================================================= */
.ethmar-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    animation: drawerFadeIn 0.2s ease-out;
}

.ethmar-drawer-backdrop.active {
    display: block;
}

.ethmar-drawer-card {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85%;
    height: 100%;
    background: var(--ethmar-surface);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    padding: 20px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl;
}

.ethmar-drawer-backdrop.active .ethmar-drawer-card {
    transform: translateX(0);
}

.ethmar-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.ethmar-drawer-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--ethmar-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ethmar-notif-item {
    background: var(--ethmar-secondary-container);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    border-inline-start: 4px solid var(--ethmar-primary);
}

.ethmar-notif-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ethmar-notif-body {
    font-size: 11px;
    color: var(--ethmar-on-surface-variant);
    line-height: 1.4;
}

.ethmar-notif-time {
    font-size: 10px;
    color: var(--ethmar-outline);
    margin-top: 6px;
    text-align: left;
}
