/* ============================================================
   🌾 FARM PLAY2025 — Design System
   ============================================================ */

:root {
    /* Brand */
    --brand-50:  #f0fdf4;
    --brand-100: #dcfce7;
    --brand-200: #bbf7d0;
    --brand-300: #86efac;
    --brand-400: #4ade80;
    --brand-500: #22c55e;
    --brand-600: #16a34a;
    --brand-700: #15803d;
    --brand-800: #166534;
    --brand-900: #14532d;

    /* Earth / wood */
    --earth-100: #fdf4e3;
    --earth-300: #e2c995;
    --earth-500: #b08855;
    --earth-700: #6f4f2a;
    --earth-900: #3d2912;

    /* Accents */
    --gold:   #fbbf24;
    --gold-d: #d97706;
    --gem:    #a78bfa;
    --gem-d:  #7c3aed;
    --water:  #38bdf8;
    --water-d:#0284c7;
    --energy: #f97316;
    --xp:     #facc15;
    --danger: #ef4444;
    --fire:   #f43f5e;

    /* Neutral */
    --ink-900:#0f1d14;
    --ink-700:#27392c;
    --ink-500:#5b6e5f;
    --ink-300:#a3b3a4;
    --ink-100:#e8efe6;
    --paper:  #ffffff;
    --paper-2:#fafdf8;

    /* Surface tokens */
    --bg-app:
        radial-gradient(1200px 600px at 90% -10%, #d9f4c7 0%, transparent 60%),
        radial-gradient(900px 500px at -10% 110%, #c5ead7 0%, transparent 55%),
        linear-gradient(180deg, #eef9e3 0%, #d8efc6 100%);

    --shadow-sm: 0 1px 2px rgba(20, 60, 30, .08);
    --shadow:    0 4px 14px rgba(20, 60, 30, .12);
    --shadow-lg: 0 16px 40px rgba(20, 60, 30, .18);
    --ring-brand: 0 0 0 4px rgba(34, 197, 94, .25);

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --t-fast: .15s ease;
    --t-base: .25s cubic-bezier(.2,.8,.2,1);
    --t-slow: .45s cubic-bezier(.2,.8,.2,1);

    --font: "Tajawal", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

/* ====== Reset ====== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink-900);
    background: var(--bg-app);
    background-attachment: fixed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-800); }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--brand-200); color: var(--ink-900); }

/* ============================================================
   TOPBAR  (الترويسة الزجاجية)
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    background: linear-gradient(180deg, rgba(20,83,45,.92), rgba(22,101,52,.85));
    color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: .3px;
    flex-shrink: 0;
}
.brand-logo {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(145deg, #facc15, #f97316 50%, #16a34a);
    display: grid; place-items: center;
    font-size: 22px;
    box-shadow: 0 6px 14px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.4);
}
.brand-text small {
    display: block;
    font-weight: 500;
    opacity: .8;
    font-size: 11px;
}

/* HUD chips (gold/gems/energy) */
.hud {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-right: auto;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    color: #fff;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    transition: var(--t-base);
}
.chip:hover { background: rgba(255,255,255,.2); }
.chip-icon { font-size: 15px; line-height: 1; }
.chip.gold   { box-shadow: inset 0 0 0 1px rgba(251,191,36,.45); }
.chip.gem    { box-shadow: inset 0 0 0 1px rgba(167,139,250,.45); }
.chip.energy { box-shadow: inset 0 0 0 1px rgba(249,115,22,.45); }
.chip.water  { box-shadow: inset 0 0 0 1px rgba(56,189,248,.45); }
.chip.xp     { box-shadow: inset 0 0 0 1px rgba(250,204,21,.45); }
.chip.level  { background: linear-gradient(135deg, var(--gold), var(--gold-d)); border:none; color:#3d2912; }

/* Avatar / user button */
.user-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    color: #fff;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    transition: var(--t-base);
}
.user-btn:hover { background: rgba(255,255,255,.16); }
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(145deg, #4ade80, #15803d);
    color: #fff;
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.menu-toggle {
    display: none;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    color: #fff;
    width: 38px; height: 38px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
}

/* ============================================================
   NAVIGATION  (شريط جانبي عمودي)
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    max-width: 1400px;
    margin: 0 auto;
    gap: 18px;
    padding: 18px;
}
.sidenav {
    position: sticky;
    top: 78px;
    align-self: start;
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(34,197,94,.12);
    border-radius: var(--radius-lg);
    padding: 10px;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}
.sidenav-section {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-500);
    padding: 10px 12px 4px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--ink-700);
    font-weight: 600;
    font-size: 14px;
    transition: var(--t-base);
    position: relative;
}
.nav-link:hover {
    background: var(--brand-50);
    color: var(--brand-800);
    transform: translateX(-2px);
}
.nav-link.active {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    color: #fff;
    box-shadow: 0 6px 14px rgba(22,101,52,.35);
}
.nav-link .nav-icon {
    width: 30px; height: 30px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: var(--brand-100);
    font-size: 16px;
    transition: var(--t-base);
}
.nav-link.active .nav-icon {
    background: rgba(255,255,255,.22);
}
.nav-link .badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 800;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main { min-width: 0; }

/* Page header */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.page-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    color: var(--ink-900);
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-title .dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(34,197,94,.18);
    animation: pulse 1.6s ease-in-out infinite;
}
.page-sub { color: var(--ink-500); font-size: 13px; }
@keyframes pulse {
    50% { transform: scale(1.4); opacity: .6; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--paper);
    border: 1px solid rgba(20,60,30,.06);
    border-radius: var(--radius-lg);
    padding: 18px 20px 20px;
    box-shadow: var(--shadow);
    transition: var(--t-base);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-glass {
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.45);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--ink-900);
}
.card-sub { font-size: 12px; color: var(--ink-500); }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* Stat tiles */
.stat {
    background: linear-gradient(145deg, var(--paper), var(--paper-2));
    border: 1px solid rgba(20,60,30,.06);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--t-base);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: "";
    position: absolute;
    inset: auto -30px -30px auto;
    width: 100px; height: 100px;
    border-radius: 50%;
    opacity: .1;
    background: var(--brand-400);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 22px;
    background: var(--brand-100);
    color: var(--brand-800);
}
.stat-icon.gold   { background: #fef3c7; color: var(--gold-d); }
.stat-icon.gem    { background: #ede9fe; color: var(--gem-d); }
.stat-icon.water  { background: #e0f2fe; color: var(--water-d); }
.stat-icon.energy { background: #ffedd5; color: #c2410c; }
.stat-icon.xp     { background: #fef9c3; color: #a16207; }
.stat-label { font-size: 11px; color: var(--ink-500); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--ink-900); }

/* Progress bars */
.bar {
    width: 100%;
    height: 8px;
    background: var(--ink-100);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
    border-radius: 999px;
    transition: width var(--t-slow);
    position: relative;
    overflow: hidden;
}
.bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
    animation: shimmer 2s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.bar-xp     .bar-fill { background: linear-gradient(90deg, #fde047, #ca8a04); }
.bar-energy .bar-fill { background: linear-gradient(90deg, #fb923c, #c2410c); }
.bar-water  .bar-fill { background: linear-gradient(90deg, #7dd3fc, #0284c7); }
.bar-storage .bar-fill{ background: linear-gradient(90deg, #a3e635, #4d7c0f); }
.bar-danger .bar-fill { background: linear-gradient(90deg, #fca5a5, #dc2626); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: var(--t-base);
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    color: #fff;
    box-shadow: 0 6px 14px rgba(22,101,52,.35), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(22,101,52,.45); }

.btn-gold {
    background: linear-gradient(145deg, #fde047, #d97706);
    color: #3d2912;
    box-shadow: 0 6px 14px rgba(217,119,6,.35), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn-gold:hover:not(:disabled) { transform: translateY(-2px); }

.btn-ghost {
    background: transparent;
    border-color: var(--brand-200);
    color: var(--brand-800);
}
.btn-ghost:hover:not(:disabled) { background: var(--brand-50); }

.btn-soft {
    background: var(--brand-50);
    color: var(--brand-800);
    border-color: var(--brand-100);
}
.btn-soft:hover:not(:disabled) { background: var(--brand-100); }

.btn-danger {
    background: linear-gradient(145deg, #f87171, #b91c1c);
    color: #fff;
}
.btn-water {
    background: linear-gradient(145deg, #38bdf8, #0369a1);
    color: #fff;
    box-shadow: 0 6px 14px rgba(2,132,199,.35);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 10px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 14px; }

/* ============================================================
   FORMS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-500); }
.input, .select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--ink-100);
    background: var(--paper);
    font: inherit;
    color: var(--ink-900);
    transition: var(--t-base);
}
.input:focus, .select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--ring-brand);
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table th {
    background: var(--brand-50);
    color: var(--brand-900);
    font-weight: 800;
    padding: 10px 12px;
    text-align: right;
    font-size: 12px;
    letter-spacing: .3px;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ink-100);
}
.table tbody tr:hover { background: var(--brand-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES & TAGS
   ============================================================ */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: var(--ink-100);
    color: var(--ink-700);
}
.tag-success { background:#dcfce7; color: var(--brand-800); }
.tag-warn    { background:#fef3c7; color:#92400e; }
.tag-danger  { background:#fee2e2; color:#991b1b; }
.tag-info    { background:#e0f2fe; color:#075985; }
.tag-rare    { background: linear-gradient(135deg,#c4b5fd,#7c3aed); color:#fff; }
.tag-epic    { background: linear-gradient(135deg,#fcd34d,#d97706); color:#3d2912; }

/* ============================================================
   TOASTS
   ============================================================ */
#toast-stack {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: min(380px, 92vw);
}
.toast {
    pointer-events: auto;
    background: rgba(15, 29, 20, .92);
    color: #fff;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.1);
    padding: 12px 14px;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    animation: toast-in .35s cubic-bezier(.2,.8,.2,1);
}
.toast.toast-out { animation: toast-out .25s ease forwards; }
.toast-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    display: grid; place-items: center;
    flex-shrink: 0;
    font-size: 17px;
}
.toast.success .toast-icon { background: linear-gradient(135deg, #4ade80, #15803d); }
.toast.error   .toast-icon { background: linear-gradient(135deg, #fca5a5, #b91c1c); }
.toast.info    .toast-icon { background: linear-gradient(135deg, #7dd3fc, #0369a1); }
.toast.warn    .toast-icon { background: linear-gradient(135deg, #fcd34d, #b45309); }
@keyframes toast-in  { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-20px); opacity: 0; } }

/* ============================================================
   FLOATING +N (gold gain animation)
   ============================================================ */
.float-text {
    position: fixed;
    pointer-events: none;
    font-weight: 900;
    font-size: 18px;
    z-index: 998;
    animation: float-up 1.4s ease-out forwards;
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.float-text.gold  { color: #fde047; }
.float-text.xp    { color: #f0abfc; }
.float-text.water { color: #7dd3fc; }
@keyframes float-up {
    0%   { transform: translate(-50%, 0)    scale(.7); opacity: 0; }
    20%  { transform: translate(-50%, -12px) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -80px) scale(.9); opacity: 0; }
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; padding: 12px; }
    .sidenav {
        position: fixed;
        top: 64px;
        right: -280px;
        width: 260px;
        height: calc(100vh - 64px);
        border-radius: 0;
        z-index: 99;
        transition: right var(--t-base);
    }
    .sidenav.open { right: 0; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
    .menu-toggle { display: grid; place-items: center; }
    .hud { gap: 6px; }
    .chip { padding: 4px 9px; font-size: 12px; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .nav-overlay {
        position: fixed; inset: 64px 0 0 0; background: rgba(0,0,0,.4);
        z-index: 98; opacity: 0; pointer-events: none; transition: opacity var(--t-base);
    }
    .nav-overlay.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 520px) {
    .grid-4 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .brand-text { display: none; }
    .page-title { font-size: 19px; }
}

/* utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
