/* =====================================================
   AgroRent — custom styles on top of Tailwind CDN
   Earthy, warm, distinctive. Not generic AI-template look.
   ===================================================== */

:root {
    --leaf-50:  #f0f7ee;
    --leaf-100: #d9ecd3;
    --leaf-200: #b1d6a4;
    --leaf-300: #84bd6f;
    --leaf-400: #5ea14a;
    --leaf-500: #3f8430;
    --leaf-600: #2f6924;
    --leaf-700: #1a5d3a;   /* primary deep green */
    --leaf-800: #144528;
    --leaf-900: #0d2e1b;

    --soil-50:  #fdfaf2;
    --soil-100: #fef7ed;   /* cream backdrop */
    --soil-200: #f5ead0;
    --soil-300: #e8d6a8;
    --soil-400: #d97706;   /* warm amber accent */
    --soil-500: #b45309;

    --grain:    #fbf8f0;
    --ink:      #1c1917;
    --ink-soft: #44403c;
    --rule:     #e7e5e4;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--soil-100);
    color: var(--ink);
    /* Subtle paper-grain texture */
    background-image:
        radial-gradient(circle at 1px 1px, rgba(26,93,58,0.04) 1px, transparent 0);
    background-size: 24px 24px;
}

.font-display {
    font-family: 'Fraunces', 'Georgia', serif;
    font-optical-sizing: auto;
    font-variation-settings: "SOFT" 30, "WONK" 0;
    letter-spacing: -0.01em;
}

/* Brand colors as utilities (works without compiling Tailwind) */
.bg-leaf    { background-color: var(--leaf-700); }
.bg-leaf-50 { background-color: var(--leaf-50); }
.bg-leaf-100{ background-color: var(--leaf-100); }
.bg-leaf-800{ background-color: var(--leaf-800); }
.bg-soil-100{ background-color: var(--soil-100); }
.bg-soil-200{ background-color: var(--soil-200); }
.bg-amber-accent { background-color: var(--soil-400); }
.bg-grain   { background-color: var(--grain); }

.text-leaf       { color: var(--leaf-700); }
.text-leaf-600   { color: var(--leaf-600); }
.text-leaf-800   { color: var(--leaf-800); }
.text-amber-accent { color: var(--soil-400); }
.text-ink        { color: var(--ink); }
.text-ink-soft   { color: var(--ink-soft); }

.border-leaf      { border-color: var(--leaf-700); }
.border-leaf-100  { border-color: var(--leaf-100); }
.border-rule      { border-color: var(--rule); }

.ring-leaf:focus { outline: 2px solid var(--leaf-500); outline-offset: 2px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.25rem;
    transition: transform 80ms ease, background-color 120ms ease, box-shadow 120ms ease;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--leaf-700);
    color: white;
    box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 1px 2px rgba(20,69,40,0.18);
}
.btn-primary:hover { background: var(--leaf-800); }
.btn-amber {
    background: var(--soil-400);
    color: white;
}
.btn-amber:hover { background: var(--soil-500); }
.btn-ghost {
    background: transparent;
    color: var(--leaf-800);
    border-color: var(--leaf-100);
}
.btn-ghost:hover { background: var(--leaf-50); }
.btn-danger {
    background: #fff;
    color: #b91c1c;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

/* Card */
.card {
    background: white;
    border: 1px solid var(--rule);
    border-radius: 0.875rem;
    overflow: hidden;
    transition: transform 160ms ease, box-shadow 160ms ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -12px rgba(20,69,40,0.18);
}

/* Form */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--rule);
    background: #fff;
    color: var(--ink);
    font-size: 0.9375rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--leaf-500);
    box-shadow: 0 0 0 3px rgba(63,132,48,0.18);
}
.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--ink-soft);
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}
.form-error {
    color: #b91c1c;
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Chip */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--leaf-50);
    color: var(--leaf-800);
    border: 1px solid var(--leaf-100);
    font-size: 0.8125rem;
    font-weight: 500;
}
.chip-amber {
    background: #fff7ed;
    color: #92400e;
    border-color: #fde68a;
}
.chip-tag {
    background: transparent;
    color: var(--ink-soft);
    border: 1px dashed var(--leaf-200);
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.chip-tag:hover {
    background: var(--leaf-50);
    color: var(--leaf-800);
    border-style: solid;
}
.chip-tag::before {
    content: '#';
    margin-right: 0.15rem;
    opacity: 0.5;
}

/* Avatar with initials */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: var(--leaf-700);
    color: var(--leaf-50);
    font-family: 'Fraunces', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Slide-in hero motion */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.rise        { animation: rise 480ms cubic-bezier(0.2,0.7,0.2,1) both; }
.rise-delay-1 { animation-delay: 80ms; }
.rise-delay-2 { animation-delay: 160ms; }
.rise-delay-3 { animation-delay: 240ms; }

/* Subtle hero pattern */
.hero-pattern {
    background:
      radial-gradient(60% 80% at 80% 20%, rgba(217,119,6,0.10), transparent 60%),
      radial-gradient(50% 70% at 10% 90%, rgba(26,93,58,0.10), transparent 60%);
}

/* Mobile sticky action bar (rental detail) */
.mobile-sticky-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--rule);
    padding: 0.75rem 1rem;
    z-index: 50;
    box-shadow: 0 -8px 24px -16px rgba(0,0,0,0.18);
}
@media (min-width: 1024px) {
    .mobile-sticky-bar { display: none; }
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* Image gallery thumb strip */
.thumb {
    width: 64px; height: 64px;
    border-radius: 0.5rem;
    border: 2px solid transparent;
    object-fit: cover;
    cursor: pointer;
    transition: border-color 120ms ease;
}
.thumb.active, .thumb:hover { border-color: var(--leaf-500); }

/* ===== Image dropzone + reorderable tiles ===== */
.dropzone {
    border: 2px dashed var(--leaf-200);
    border-radius: 0.75rem;
    background: var(--leaf-50);
    padding: 1.5rem;
    text-align: center;
    transition: background-color 120ms ease, border-color 120ms ease;
    cursor: pointer;
}
.dropzone:hover,
.dropzone.is-over {
    background: var(--leaf-100);
    border-color: var(--leaf-500);
}
.dropzone-hint {
    color: var(--leaf-800);
    font-size: 0.875rem;
}
.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}
@media (min-width: 640px) {
    .tile-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.tile {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--soil-200);
    border-radius: 0.625rem;
    overflow: hidden;
    border: 1px solid var(--rule);
    user-select: none;
}
.tile.dragging { opacity: 0.4; }
.tile.drop-target { outline: 2px solid var(--leaf-500); outline-offset: -2px; }
.tile img {
    width: 100%; height: 100%; object-fit: cover;
    pointer-events: none;
}
.tile-controls {
    position: absolute;
    top: 0.25rem; right: 0.25rem;
    display: flex; gap: 0.25rem;
}
.tile-btn {
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--rule);
    border-radius: 999px;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; line-height: 1;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.tile-btn:hover { background: white; color: var(--leaf-800); }
.tile-btn.tile-remove:hover { color: #b91c1c; border-color: #fecaca; }
.tile-position {
    position: absolute;
    bottom: 0.25rem; left: 0.25rem;
    background: rgba(20,69,40,0.85);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    letter-spacing: 0.04em;
    pointer-events: none;
}
.tile-drag-handle {
    position: absolute;
    inset: 0;
    cursor: grab;
}
.tile-drag-handle:active { cursor: grabbing; }

/* Pending (compressing) tile */
.tile.tile-pending {
    background: linear-gradient(135deg, var(--soil-200), var(--leaf-50));
}
.tile-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid var(--leaf-200, #cce0c7);
    border-top-color: var(--leaf-700);
    border-radius: 50%;
    animation: tile-spin 0.8s linear infinite;
}
@keyframes tile-spin { to { transform: rotate(360deg); } }
.tile-note {
    position: absolute;
    bottom: 0.25rem;
    right: 0.25rem;
    max-width: calc(100% - 0.5rem);
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink-soft);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    line-height: 1.2;
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tile-pending .tile-note {
    left: 0.25rem;
    right: 0.25rem;
    bottom: 0.25rem;
    text-align: center;
    max-width: none;
}

/* Dropzone (single-image) compressing/result status line */
.dropzone-status {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink-soft);
    text-align: center;
    transition: color 0.15s;
}
.dropzone-status:not(.hidden) { color: var(--leaf-700); }
[data-dropzone].is-compressing { opacity: 0.7; }

/* Upload progress bar */
.upload-progress {
    background: white;
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}
.upload-progress-track {
    width: 100%;
    height: 8px;
    background: var(--soil-200);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--leaf-500), var(--leaf-700));
    border-radius: 999px;
    transition: width 0.15s ease;
}
.upload-progress-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* ===== Image lightbox ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(13, 46, 27, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    cursor: zoom-out;
    animation: rise 200ms ease both;
}
.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.5rem;
    cursor: default;
}
.lightbox-close {
    position: absolute;
    top: 1rem; right: 1rem;
    width: 40px; height: 40px;
    border-radius: 999px;
    background: white;
    color: var(--ink);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    border-radius: 999px;
    background: rgba(255,255,255,0.95);
    color: var(--ink);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
@media (max-width: 640px) {
    .lightbox-nav { width: 36px; height: 36px; font-size: 1.1rem; }
}

/* ===== Gallery main with zoom cursor ===== */
.gallery-main {
    cursor: zoom-in;
}
.gallery-main.is-video {
    cursor: default;
}
.gallery-thumb-video {
    position: relative;
    background: var(--leaf-900);
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-thumb-video::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M8 5v14l11-7z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 40%;
    opacity: 0.95;
    pointer-events: none;
}

/* ===== Small dropzone variant (for profile/cover photo upload) ===== */
.photo-drop {
    position: relative;
    transition: outline-color 120ms ease, background-color 120ms ease;
    cursor: pointer;
    outline: 2px dashed transparent;
    outline-offset: 4px;
    border-radius: 0.5rem;
}
.photo-drop:hover {
    outline-color: var(--leaf-200);
}
.photo-drop.is-over {
    outline-color: var(--leaf-500);
    outline-style: solid;
    background-color: var(--leaf-50);
}
.photo-drop-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--leaf-800);
    background: rgba(217, 236, 211, 0.65);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 120ms ease;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: inherit;
}
.photo-drop.is-over .photo-drop-hint {
    opacity: 1;
}

/* ===== Responsive tables: stacked-card layout on mobile ===== */
/* Apply .responsive-table to a <table>. Add data-label="Column" on each <td>. */
@media (max-width: 639px) {
    .responsive-table thead {
        display: none;
    }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }
    .responsive-table tr {
        background: white;
        border-radius: 0.5rem;
        border: 1px solid var(--rule);
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
    .responsive-table td {
        padding: 0.4rem 0;
        border: none;
        text-align: left;
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
        align-items: center;
    }
    .responsive-table td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--ink-soft);
        font-weight: 600;
        flex-shrink: 0;
    }
    .responsive-table td:last-child {
        padding-top: 0.75rem;
        border-top: 1px solid var(--rule);
        margin-top: 0.4rem;
    }
    /* The actions cell — let the buttons wrap nicely */
    .responsive-table td.cell-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .responsive-table td.cell-actions::before {
        display: none;
    }
}

/* Always-overflow wrapper to keep the table scrollable horizontally on
   tablet-ish sizes between sm and lg where we don't quite stack yet. */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Password input with eye toggle ---------- */
.password-wrap {
    position: relative;
    display: block;
}
.password-toggle {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.password-toggle:hover {
    background-color: var(--leaf-50);
    color: var(--leaf-700);
}
.password-toggle:focus-visible {
    outline: 2px solid var(--leaf-400);
    outline-offset: 1px;
}

/* ---------- Copyable phone number chip ---------- */
.phone-copy {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border: 1px dashed var(--rule);
    border-radius: 9999px;
    background: var(--grain);
    color: var(--ink-soft);
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.phone-copy:hover {
    color: var(--leaf-800);
    border-color: var(--leaf-300);
    background: var(--leaf-50);
}
.phone-copy:focus-visible {
    outline: 2px solid var(--leaf-400);
    outline-offset: 1px;
}
.phone-copy .phone-copy-icon { flex-shrink: 0; opacity: 0.85; }
.phone-copy .phone-copy-ok {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--leaf-700);
    color: white;
    border-radius: inherit;
    font-size: 0.75rem;
    opacity: 0;
    transform: scale(0.94);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.phone-copy.copied .phone-copy-ok {
    display: flex !important;   /* override inline display:none safety fallback */
    opacity: 1;
    transform: scale(1);
}

/* ---------- Custom scrollbars (cross-browser) ---------- */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--leaf-200, #c1d8b6) transparent; }

/* WebKit / Blink (Chrome, Edge, Safari) */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--leaf-200, #c1d8b6);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--leaf-400, #91b97f); background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-corner { background: transparent; }

/* For the category filter sidebar specifically (taller area, needs visible thumb) */
.scroll-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--leaf-300, #a4c592) transparent;
}
.scroll-thin::-webkit-scrollbar { width: 6px; }
.scroll-thin::-webkit-scrollbar-thumb {
    background: var(--leaf-300, #a4c592);
    border-radius: 999px;
}

/* Storefront tab nav: never overflow horizontally */
#tabs { min-width: 0; }
#tabs > a { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Password strength checklist ---------- */
.pw-strength {
    list-style: none;
    margin: 0.4rem 0 0 0;
    padding: 0;
    display: grid;
    gap: 0.15rem;
    font-size: 0.72rem;
    color: var(--ink-soft);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out, margin 0.2s ease-out;
}
.pw-strength.show { max-height: 8rem; margin-top: 0.4rem; }
.pw-strength li { position: relative; padding-left: 1.1rem; transition: color 0.15s; }
.pw-strength li::before {
    content: '○';
    position: absolute;
    left: 0;
    color: var(--ink-soft);
    font-weight: bold;
}
.pw-strength li.ok { color: var(--leaf-700); }
.pw-strength li.ok::before { content: '✓'; color: var(--leaf-700); }

/* ---------- Custom confirm modal ---------- */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 24, 0.55);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: cfm-fade 0.15s ease-out;
}
.confirm-backdrop.is-open { display: flex; }
@keyframes cfm-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes cfm-pop   { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.confirm-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    padding: 1.75rem 1.5rem 1.25rem;
    max-width: 24rem;
    width: 100%;
    text-align: center;
    animation: cfm-pop 0.18s ease-out;
}
.confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.75rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #b45309;
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-msg {
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1.25rem 0;
}
.confirm-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}
.confirm-actions .btn { min-width: 6.5rem; }

/* Lightbox video slide (16:9, sized to fit viewport like images do) */
.lightbox-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-video-wrap {
    width: min(92vw, 1280px);
    aspect-ratio: 16 / 9;
    max-height: 88vh;
    background: black;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.lightbox-video-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

/* Additional chip color variants for credits status */
.chip-green { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.chip-red   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
