/* ============================================================
   MINHA GRANA — CSS
   Design mobile-first, PWA-ready
   ============================================================ */

/* --- Reset e Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #10b981;
    --green-dark: #059669;
    --green-light: #d1fae5;
    --blue: #3b82f6;
    --blue-light: #dbeafe;
    --red: #ef4444;
    --red-light: #fee2e2;
    --yellow: #f59e0b;
    --yellow-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* --- App Header --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-logo { font-size: 1.5rem; }
.header-title { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.user-badge {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
}
.user-name { font-size: 0.85rem; font-weight: 500; color: var(--gray-700); }
.user-role-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-pai { background: var(--blue-light); color: var(--blue); }
.role-filho { background: var(--green-light); color: var(--green-dark); }

/* --- Bottom Nav (Mobile) --- */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    justify-content: space-around;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.65rem;
    color: var(--gray-400);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}
.nav-item:hover, .nav-item.active { color: var(--green); text-decoration: none; }
.nav-icon { font-size: 1.3rem; }
.nav-label { font-weight: 500; }

/* --- Main Content --- */
.app-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}
.app-main.has-nav { padding-bottom: 5rem; }

/* --- Auth Pages --- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--green) 0%, #065f46 100%);
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}
.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-logo { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.auth-header h1 { font-size: 1.5rem; color: var(--gray-900); }
.auth-subtitle { color: var(--gray-500); font-size: 0.9rem; margin-top: 0.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* --- Flash Messages --- */
.flash-container {
    max-width: 900px;
    margin: 0.5rem auto;
    padding: 0 1rem;
}
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}
.flash-success { background: var(--green-light); color: var(--green-dark); }
.flash-danger { background: var(--red-light); color: var(--red); }
.flash-warning { background: var(--yellow-light); color: #92400e; }
.flash-info { background: var(--blue-light); color: var(--blue); }
.flash-close {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: inherit; opacity: 0.6;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- Page Header --- */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; color: var(--gray-900); }
.page-desc { color: var(--gray-500); font-size: 0.9rem; margin-top: 0.25rem; }

/* --- Section --- */
.section { margin-bottom: 1.5rem; }
.section-title {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Cards Grid --- */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Card --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}
.card-filho { border-left: 4px solid var(--green); }
.card-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.card-info h3 { font-size: 1rem; color: var(--gray-900); }

/* --- Avatar --- */
.avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* --- Stats --- */
.card-stats {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: 0.75rem;
}
.stat { flex: 1; text-align: center; }
.stat-value { display: block; font-size: 1.2rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.7rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Hero Points (filho) --- */
.hero-points {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: linear-gradient(135deg, var(--green) 0%, #065f46 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.hero-circle {
    width: 100px; height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2) !important;
    border: 3px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}
.hero-pts { font-size: 2rem; font-weight: 800; line-height: 1; }
.hero-label { font-size: 0.7rem; text-transform: uppercase; opacity: 0.8; }
.hero-details { display: flex; flex-direction: column; gap: 0.5rem; }
.hero-stat {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
}

/* --- Task List --- */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }
.task-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}
.task-inativa { opacity: 0.5; }
.task-top {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.task-icon-lg { font-size: 2rem; flex-shrink: 0; }
.task-info { flex: 1; }
.task-info h3 { font-size: 0.95rem; color: var(--gray-900); }
.task-pts {
    text-align: center;
    background: var(--green-light);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.pts-value { font-weight: 800; color: var(--green-dark); font-size: 1.1rem; display: block; line-height: 1; }
.pts-label { font-size: 0.6rem; color: var(--green); text-transform: uppercase; }

.task-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.task-submit-form { margin-top: 0.75rem; border-top: 1px solid var(--gray-100); padding-top: 0.75rem; }
.task-submit-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Approval --- */
.approval-list { display: flex; flex-direction: column; gap: 0.75rem; }
.approval-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--yellow);
}
.approval-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.task-icon { font-size: 1.5rem; }
.approval-info { flex: 1; }
.approval-info strong { display: block; font-size: 0.95rem; }
.approval-note {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}
.evidence-photo {
    margin: 0.5rem 0;
}
.evidence-photo img {
    max-height: 200px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--gray-200);
}
.approval-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* --- Exec List --- */
.exec-list { display: flex; flex-direction: column; gap: 0.5rem; }
.exec-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border-left: 3px solid var(--gray-300);
}
.exec-item.status-aprovada { border-left-color: var(--green); }
.exec-item.status-rejeitada { border-left-color: var(--red); }
.exec-item.status-pendente { border-left-color: var(--yellow); }
.exec-icon { font-size: 1.3rem; flex-shrink: 0; }
.exec-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.exec-right { text-align: right; flex-shrink: 0; }
.exec-pts { font-weight: 700; color: var(--green-dark); }

/* --- Status Badge --- */
.status-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 600;
    display: inline-block;
}
.status-badge.status-pendente { background: var(--yellow-light); color: #92400e; }
.status-badge.status-aprovada { background: var(--green-light); color: var(--green-dark); }
.status-badge.status-rejeitada { background: var(--red-light); color: var(--red); }

/* --- Badges --- */
.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}
.badge-info { background: var(--yellow-light); color: #92400e; }
.count-badge {
    background: var(--green);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}

/* --- Forms --- */
.form-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color 0.15s;
    background: var(--white);
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.form-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.flex-1 { flex: 1; min-width: 120px; }
.flex-2 { flex: 2; min-width: 200px; }
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.input-sm {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font);
    min-width: 0;
    flex: 1;
}
.input-sm:focus {
    outline: none;
    border-color: var(--green);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(0.95); }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-dark); }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* --- Transfer Form --- */
.transfer-form { margin-top: 0.5rem; }
.transfer-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* --- Edit Details --- */
.edit-details { margin: 0.5rem 0; }
.edit-details summary { cursor: pointer; list-style: none; }
.edit-details summary::-webkit-details-marker { display: none; }
.edit-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--gray-400);
}
.empty-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }

/* --- Foto --- */
.foto-btn { position: relative; overflow: hidden; }
.foto-status { font-size: 0.75rem; color: var(--gray-500); white-space: nowrap; }

/* --- Modal foto --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
}

/* --- Helpers --- */
.text-green { color: var(--green-dark); }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }

/* --- Desktop (>768px) --- */
@media (min-width: 768px) {
    .nav-bottom {
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        bottom: 0;
        width: 80px;
        flex-direction: column;
        justify-content: flex-start;
        padding: 4.5rem 0 1rem;
        border-top: none;
        border-right: 1px solid var(--gray-200);
        box-shadow: 2px 0 10px rgba(0,0,0,0.03);
    }
    .nav-item { padding: 0.75rem 0.5rem; }
    .app-header { padding-left: 96px; }
    .app-main { margin-left: 80px; padding: 1.5rem 2rem 2rem; }
    .flash-container { margin-left: 80px; }
    .hero-points { padding: 2rem; }
}

/* --- Mobile small (<380px) --- */
@media (max-width: 380px) {
    .header-title { display: none; }
    .user-name { display: none; }
    .hero-points { flex-direction: column; text-align: center; }
    .hero-stat { font-size: 0.85rem; }
    .form-row { flex-direction: column; }
    .flex-1, .flex-2 { min-width: 100%; }
}
