/* Soorna Trip Expense Manager - آکادمی سورنا v1.1 */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
    --st-primary:      #6366f1;
    --st-primary-dark: #4f46e5;
    --st-secondary:    #ec4899;
    --st-success:      #10b981;
    --st-danger:       #ef4444;
    --st-warning:      #f59e0b;
    --st-bg:           #f8f7ff;
    --st-surface:      #ffffff;
    --st-border:       #e5e7eb;
    --st-text:         #111827;
    --st-muted:        #6b7280;
    --st-radius:       14px;
    --st-shadow:       0 4px 24px rgba(99,102,241,.10);
    --st-shadow-lg:    0 12px 40px rgba(99,102,241,.18);
}

#soorna-trip-app * { box-sizing: border-box; font-family: 'Vazirmatn', Tahoma, sans-serif; }

#soorna-trip-app {
    direction: rtl;
    max-width: 520px;
    margin: 0 auto;
    background: var(--st-bg);
    min-height: 540px;
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--st-shadow-lg);
}

/* ── SCREENS ── */
.st-screen { display: none; }
.st-screen.active { display: block; }

/* ── LANDING ── */
#screen-landing {
    background: linear-gradient(145deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    min-height: 540px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 24px 40px;
    text-align: center;
}
#screen-landing.active { display: flex; }

.st-hero { margin-bottom: 36px; }
.st-logo svg { width: 80px; height: 80px; margin-bottom: 16px; filter: drop-shadow(0 4px 16px rgba(0,0,0,.3)); }
.st-brand { font-size: 1.9rem; font-weight: 800; color: #fff; margin: 0 0 8px; }
.st-tagline { color: rgba(255,255,255,.8); font-size: .95rem; font-weight: 300; margin: 0; }

.st-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.st-powered { margin-top: 28px; color: rgba(255,255,255,.6); font-size: .78rem; }
.st-powered a { color: rgba(255,255,255,.9); text-decoration: none; font-weight: 600; }

/* ── BUTTONS ── */
.st-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 22px; border-radius: 12px; border: none; cursor: pointer;
    font-family: inherit; font-size: .95rem; font-weight: 600;
    transition: all .2s ease; text-decoration: none; white-space: nowrap;
}
.st-btn:active { transform: scale(.97); }
.st-btn:disabled { opacity: .5; cursor: not-allowed; }

/* On gradient bg (landing) */
.st-btn-primary    { background: #fff; color: var(--st-primary); box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.st-btn-primary:hover { background: #f0f0ff; }
.st-btn-secondary  { background: rgba(255,255,255,.18); color: #fff; border: 2px solid rgba(255,255,255,.4); }
.st-btn-secondary:hover { background: rgba(255,255,255,.28); }
.st-btn-ghost      { background: transparent; color: rgba(255,255,255,.85); border: 1.5px solid rgba(255,255,255,.3); }
.st-btn-ghost:hover { background: rgba(255,255,255,.12); }

/* On light bg (inside screens) */
.st-btn-secondary-dark { background: var(--st-surface); color: var(--st-primary); border: 2px solid var(--st-primary); }
.st-btn-secondary-dark:hover { background: #ede9fe; }
.st-btn-outline    { background: transparent; color: var(--st-primary); border: 2px solid var(--st-primary); }
.st-btn-outline:hover { background: #ede9fe; }
.st-btn-danger     { background: #fef2f2; color: var(--st-danger); border: 1px solid #fecaca; }
.st-btn-danger:hover { background: #fee2e2; }

.st-btn-full { width: 100%; }
.st-btn-sm   { font-size: .85rem; padding: 9px 16px; }

/* ── HEADER ── */
.st-header {
    background: linear-gradient(135deg, var(--st-primary), var(--st-primary-dark));
    color: #fff; padding: 18px 20px;
    display: flex; align-items: center; gap: 12px;
}
.st-header h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.st-back {
    background: rgba(255,255,255,.2); border: none; color: #fff;
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    font-family: inherit; font-size: .85rem; font-weight: 600; transition: background .2s;
}
.st-back:hover { background: rgba(255,255,255,.35); }

/* ── FORM ── */
.st-form-wrap { padding: 24px 20px; }
.st-field { margin-bottom: 16px; }
.st-field label { display: block; font-size: .85rem; font-weight: 600; color: var(--st-text); margin-bottom: 6px; }
.st-field input,
.st-field textarea,
.st-field select {
    width: 100%; padding: 12px 14px;
    border: 2px solid var(--st-border); border-radius: 10px;
    font-family: inherit; font-size: .95rem; color: var(--st-text);
    background: var(--st-surface); transition: border-color .2s; outline: none;
}
.st-field input:focus,
.st-field textarea:focus,
.st-field select:focus { border-color: var(--st-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

/* ── TRIP TOPBAR ── */
.st-topbar {
    background: linear-gradient(135deg, var(--st-primary), var(--st-primary-dark));
    padding: 16px 16px; display: flex; align-items: center; gap: 10px;
}
.st-back-icon {
    background: rgba(255,255,255,.2) !important;
    color: #fff !important; font-size: 1rem !important;
    flex-shrink: 0;
}
.st-trip-title { font-size: 1rem; font-weight: 700; color: #fff; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-trip-actions { display: flex; gap: 6px; flex-shrink: 0; }
.st-icon-btn {
    width: 36px; height: 36px; border-radius: 9px;
    background: rgba(255,255,255,.2); border: none; cursor: pointer;
    font-size: 1rem; display: inline-flex; align-items: center; justify-content: center;
    transition: background .2s; color: #fff;
}
.st-icon-btn:hover { background: rgba(255,255,255,.35); }

/* ── CLOSED BANNER ── */
.st-closed-banner {
    background: #fff8e1; border-bottom: 2px solid #fde68a;
    padding: 10px 16px; font-size: .85rem; color: #92400e; font-weight: 600;
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}

/* ── CARDS ── */
.st-cards {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; padding: 14px; background: var(--st-bg);
}
.st-card {
    background: var(--st-surface); border-radius: var(--st-radius);
    padding: 14px; box-shadow: var(--st-shadow); border-right: 4px solid transparent;
}
.st-card-total   { border-right-color: var(--st-primary); }
.st-card-share   { border-right-color: var(--st-warning); }
.st-card-paid    { border-right-color: var(--st-success); }
.st-card-balance { border-right-color: var(--st-secondary); }
.st-card-label { font-size: .72rem; color: var(--st-muted); margin-bottom: 5px; font-weight: 500; }
.st-card-value { font-size: .95rem; font-weight: 700; color: var(--st-text); }
.st-card-value.credit { color: var(--st-success); }
.st-card-value.debit  { color: var(--st-danger); }

/* ── SECTION ── */
.st-section { padding: 0 16px 10px; }
.st-section-title { font-size: .8rem; font-weight: 700; color: var(--st-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }

/* ── SETTLEMENTS ── */
.st-settlement-item {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
    padding: 11px 14px; margin-bottom: 8px; font-size: .87rem;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.st-settlement-item .amount { font-weight: 700; color: var(--st-danger); margin-right: auto; white-space: nowrap; }

/* ── TABS ── */
.st-tabs {
    display: flex; padding: 0 16px; gap: 4px;
    background: var(--st-bg); border-bottom: 2px solid var(--st-border);
}
.st-tab {
    padding: 11px 18px; border: none; background: transparent; cursor: pointer;
    font-family: inherit; font-size: .88rem; font-weight: 600; color: var(--st-muted);
    border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s;
}
.st-tab.active { color: var(--st-primary); border-bottom-color: var(--st-primary); }
.st-tab-content { display: none; padding: 14px 16px; }
.st-tab-content.active { display: block; }

/* ── LIST ── */
.st-list { display: flex; flex-direction: column; gap: 9px; }
.st-empty {
    text-align: center; color: var(--st-muted); font-size: .9rem;
    padding: 28px; background: var(--st-surface); border-radius: 12px; line-height: 1.7;
}

/* ── EXPENSE ITEM ── */
.st-expense-item {
    background: var(--st-surface); border-radius: 12px; padding: 13px;
    box-shadow: var(--st-shadow); display: flex; align-items: flex-start; gap: 11px;
    animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }

.st-expense-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--st-primary), var(--st-secondary));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.st-expense-info { flex: 1; min-width: 0; }
.st-expense-title { font-weight: 700; font-size: .92rem; color: var(--st-text); margin-bottom: 2px; }
.st-expense-meta  { font-size: .75rem; color: var(--st-muted); line-height: 1.5; }
.st-expense-right { text-align: left; flex-shrink: 0; }
.st-expense-amount   { font-size: .92rem; font-weight: 800; color: var(--st-primary-dark); }
.st-expense-currency { font-size: .68rem; color: var(--st-muted); }
.st-expense-delete {
    background: none; border: none; cursor: pointer;
    color: var(--st-muted); font-size: .8rem; padding: 2px 4px;
    border-radius: 4px; transition: color .2s; display: block; width: 100%; text-align: center; margin-top: 4px;
}
.st-expense-delete:hover { color: var(--st-danger); }

/* ── MEMBER ITEM ── */
.st-member-item {
    background: var(--st-surface); border-radius: 12px;
    padding: 12px 14px; box-shadow: var(--st-shadow);
    display: flex; align-items: center; gap: 11px;
}
.st-member-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .92rem; flex-shrink: 0;
}
.st-member-info { flex: 1; }
.st-member-name { font-weight: 600; font-size: .9rem; }
.st-member-badge {
    display: inline-block; background: #ede9fe; color: var(--st-primary);
    font-size: .68rem; padding: 2px 6px; border-radius: 20px; font-weight: 600; margin-right: 5px;
}
.st-member-stats { font-size: .75rem; color: var(--st-muted); margin-top: 2px; }
.st-member-delete {
    background: none; border: none; color: var(--st-muted); cursor: pointer;
    font-size: .85rem; padding: 4px 8px; border-radius: 6px; transition: color .2s;
}
.st-member-delete:hover { color: var(--st-danger); }

/* ── TRIP CARDS (My Trips list) ── */
.st-trip-card {
    background: var(--st-surface); border-radius: 14px;
    padding: 16px; box-shadow: var(--st-shadow);
    border: 2px solid transparent; transition: border-color .2s;
}
.st-trip-card-active { border-color: var(--st-primary); }
.st-trip-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.st-trip-card-title { font-size: 1rem; font-weight: 700; color: var(--st-text); line-height: 1.3; }
.st-trip-card-badges { display: flex; gap: 5px; flex-wrap: wrap; flex-shrink: 0; }
.st-trip-card-badge { display: inline-block; font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.st-badge-active  { background: #d1fae5; color: #065f46; }
.st-badge-closed  { background: #f3f4f6; color: #6b7280; }
.st-badge-admin   { background: #ede9fe; color: var(--st-primary); }
.st-badge-current { background: #dbeafe; color: #1e40af; }
.st-trip-card-meta { font-size: .78rem; color: var(--st-muted); display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.st-trip-card-footer { display: flex; gap: 8px; }
.st-btn-switch { background: var(--st-primary); color: #fff; border: none; }
.st-btn-switch:hover { background: var(--st-primary-dark); }

/* ── MODAL ── */
.st-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9999;
    display: flex; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(4px); animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.st-modal {
    background: var(--st-surface); border-radius: 24px 24px 0 0;
    width: 100%; max-width: 520px;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    animation: slideUp .28s ease;
}
.st-modal-center { border-radius: 24px; max-width: 380px; margin: auto; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.st-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0; margin-bottom: 14px; }
.st-modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.st-modal-close {
    width: 30px; height: 30px; border-radius: 50%; background: var(--st-bg);
    border: none; cursor: pointer; font-size: .85rem;
    display: flex; align-items: center; justify-content: center; color: var(--st-muted);
}
.st-modal-body   { padding: 0 20px; }
.st-modal-footer { padding: 14px 20px; }

/* ── INVITE CODE ── */
.st-invite-code {
    font-size: 2rem; font-weight: 800; letter-spacing: 8px;
    color: var(--st-primary); background: #ede9fe; border-radius: 14px;
    padding: 16px 24px; margin: 10px auto 12px;
    display: inline-block; min-width: 200px;
}

/* ── MISC ── */
.st-divider { height: 1px; background: var(--st-border); margin: 16px 0; }

/* ── LOADING ── */
#st-loading {
    position: fixed; inset: 0; background: rgba(255,255,255,.65);
    z-index: 99999; display: flex; align-items: center; justify-content: center;
}
.st-spinner {
    width: 42px; height: 42px; border: 4px solid var(--st-border);
    border-top-color: var(--st-primary); border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 540px) {
    #soorna-trip-app { border-radius: 0; box-shadow: none; min-height: 100vh; }
    .st-cards { gap: 8px; padding: 10px; }
}
