/* e-Ranch Pro — estilos base. Prioridade: simplicidade e poucos cliques. */

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

:root {
    --color-primary: #6b4226;
    --color-primary-dark: #4a2c17;
    --color-accent: #c98a3e;
    --color-bg: #f5f2ec;
    --color-card: #ffffff;
    --color-text: #2b2b2b;
    --color-text-muted: #8a8378;
    --color-border: #e7e1d6;
    --color-success: #2e7d32;
    --color-error: #c0392b;
    --color-warning: #b8860b;
    --sidebar-bg: #3a241a;
    --sidebar-bg-active: #573523;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(30, 20, 10, .06);
    --shadow-md: 0 6px 20px rgba(30, 20, 10, .08);
    --shadow-lg: 0 14px 34px rgba(30, 20, 10, .14);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: radial-gradient(circle at 20% 20%, var(--color-accent) 0%, transparent 45%),
                linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.login-box {
    background: var(--color-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo { max-width: 120px; margin: 0 auto 1rem; display: block; }
.login-box h1 { margin: 0 0 .25rem; text-align: center; color: var(--color-primary-dark); }
.login-box .subtitle { text-align: center; color: var(--color-text-muted); margin-bottom: 1.5rem; font-style: italic; }
.login-box .form { text-align: left; max-width: none; }

/* ---------- App shell ---------- */

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

.app-sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 1.5rem 1rem 1.5rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: .2px;
    margin-bottom: .25rem;
    padding: 0 .5rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-brand img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; flex-shrink: 0; }

.sidebar-brand .brand-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(201, 138, 62, .25);
    flex-shrink: 0;
}

.sidebar-tagline {
    padding: 0 .5rem;
    margin-bottom: 1.5rem;
    font-size: .75rem;
    color: rgba(255,255,255,.45);
}

.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }

.nav-section-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    padding: 1rem .6rem .35rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: rgba(255,255,255,.75);
    padding: .55rem .65rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--sidebar-bg-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: .9;
}

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.75rem;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.header-title { font-weight: 600; color: var(--color-text-muted); font-size: .9rem; }

.header-user {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.header-user-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.header-user-name { font-weight: 600; font-size: .88rem; }
.header-user-role { font-size: .72rem; color: var(--color-text-muted); text-transform: capitalize; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .95rem;
    flex-shrink: 0;
}

.app-content { padding: 1.75rem; flex: 1; }

.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: .8rem;
}

/* ---------- Componentes ---------- */

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.page-subtitle { color: var(--color-text-muted); font-size: .88rem; margin-top: .2rem; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.1rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
}
.btn-ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.55); transform: scale(0); animation: btn-ripple-anim .6s ease-out; pointer-events: none; }
@keyframes btn-ripple-anim { to { transform: scale(2.4); opacity: 0; } }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-secondary { background: #eee; color: var(--color-text); }
.btn-secondary:hover { background: #e2e2e2; text-decoration: none; }

.link-btn {
    background: none;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    padding: 0;
    font-size: .9rem;
    text-decoration: underline;
}

.table-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--color-border);
}
.table-card-header h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.table-card-header a { font-size: .85rem; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; background: var(--color-card); border-radius: var(--radius-lg); overflow: hidden; }
.table th, .table td { padding: .8rem 1.4rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.table th { background: #faf8f4; font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbf9f5; }

.form { max-width: 480px; display: flex; flex-direction: column; gap: .35rem; }
.form label { font-weight: 600; margin-top: .5rem; font-size: .88rem; }
.form input, .form select, .form textarea {
    padding: .6rem .7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    width: 100%;
    font-family: var(--font);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(201, 138, 62, .15);
}
.form textarea { min-height: 80px; }
.form-actions { margin-top: 1rem; display: flex; gap: .75rem; }
.checkbox-inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: normal; margin-right: 1rem; }

.field-error { color: var(--color-error); font-size: .85rem; }

.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #e6f4ea; color: var(--color-success); }
.alert-error { background: #fdecea; color: var(--color-error); }

.plan-info { color: var(--color-text-muted); margin-bottom: 1rem; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; margin-bottom: 1.75rem; }

.card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card h3 { margin: 0 0 .6rem; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
.card-value { margin: 0; font-size: 1.9rem; font-weight: 800; color: var(--color-primary-dark); line-height: 1; }
.card-caption { margin: .4rem 0 0; font-size: .8rem; color: var(--color-text-muted); }

.stat-card { display: flex; align-items: flex-start; gap: 1rem; }
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; color: #fff; }
.stat-body h3 { margin: 0 0 .3rem; }

.badge { display: inline-block; padding: .25rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.badge-success { background: #e6f4ea; color: var(--color-success); }
.badge-warning { background: #fdf3e0; color: var(--color-warning); }
.badge-error   { background: #fdecea; color: var(--color-error); }
.badge-muted   { background: #ececec; color: var(--color-text-muted); }

.item-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1fr; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.item-row select, .item-row input { width: 100%; }

.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--color-text-muted); }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .app-sidebar { width: 100%; height: auto; position: relative; padding: 1rem; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .nav-section-label { display: none; }
    .app-content { padding: 1.1rem; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Horse photo gallery + crop modal ---------- */

.photo-gallery { display: flex; flex-wrap: wrap; gap: .9rem; margin: .5rem 0 1.25rem; }
.photo-gallery-item { position: relative; width: 130px; }
.photo-gallery-item img { width: 130px; height: 100px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--color-border); display: block; }
.photo-gallery-item form { position: absolute; top: -8px; right: -8px; margin: 0; }
.photo-gallery-item .btn-remove-photo {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: var(--color-error); color: #fff; cursor: pointer; font-size: .85rem;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.photo-preview { max-width: 160px; max-height: 120px; border-radius: var(--radius); margin-top: .5rem; display: block; border: 1px solid var(--color-border); }

.photo-crop-modal {
    display: none;
    position: fixed; inset: 0; background: rgba(20, 12, 6, .65);
    z-index: 1000; align-items: center; justify-content: center;
}
.photo-crop-modal.open { display: flex; }
.photo-crop-box { background: #fff; border-radius: var(--radius-lg); width: min(600px, 92vw); overflow: hidden; box-shadow: var(--shadow-lg); }
.photo-crop-header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid var(--color-border); font-weight: 700; }
.photo-crop-header button { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-text-muted); }
.photo-crop-body { height: 360px; background: #333; }
.photo-crop-body img { display: block; max-width: 100%; }
.photo-crop-footer { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.2rem; border-top: 1px solid var(--color-border); }

/* ---------- Admin help-desk widget ---------- */

#eranch-support-widget { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 900; }
#eranch-support-toggle {
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--color-primary); color: #fff; font-size: 1.5rem;
    box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center;
    transition: transform .15s ease;
}
#eranch-support-toggle:hover { transform: scale(1.08); background: var(--color-primary-dark); }
#eranch-support-panel {
    position: absolute; bottom: 74px; right: 0; width: 310px;
    background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 1.1rem; border: 1px solid var(--color-border);
}
.eranch-support-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: .5rem; color: var(--color-primary-dark); }
.eranch-support-head button { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--color-text-muted); }
.eranch-support-intro { font-size: .85rem; color: var(--color-text-muted); margin: 0 0 .75rem; }
#eranch-support-form { display: flex; flex-direction: column; gap: .5rem; }
#eranch-support-form input, #eranch-support-form textarea {
    padding: .55rem; border: 1px solid var(--color-border); border-radius: 8px; font-size: .9rem;
    width: 100%; font-family: inherit; box-sizing: border-box;
}
#eranch-support-form textarea { min-height: 80px; resize: vertical; }
#eranch-support-form button {
    background: var(--color-primary); color: #fff; border: none; border-radius: 8px;
    padding: .65rem; cursor: pointer; font-weight: 600;
}
#eranch-support-form button:hover { background: var(--color-primary-dark); }
#eranch-support-success { background: var(--color-bg); border-radius: var(--radius); padding: .8rem 1rem; font-size: .88rem; color: var(--color-primary-dark); font-weight: 600; }

@media (max-width: 700px) {
    #eranch-support-panel { width: calc(100vw - 3rem); }
}
