/* =====================================================
   TIZAMA GROUP - Main Stylesheet
   Mobile-first, Navy/Gold design system
   ===================================================== */

:root {
    --navy: #081D5C;
    --blue: #10338A;
    --gold: #FFC400;
    --gold-dark: #F5B800;
    --bg: #F0F4F9;
    --white: #FFFFFF;
    --text: #1E293B;
    --gray: #64748B;
    --light-bg: #F8FAFC;
    --border: #E2E8F0;
    --green: #10B981;
    --red: #EF4444;
    --purple: #8B5CF6;
    --orange: #F59E0B;
    --shadow: 0 4px 20px rgba(8, 29, 92, 0.08);
    --shadow-sm: 0 2px 8px rgba(8, 29, 92, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --bottom-nav-height: 64px;
    --top-bar-height: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--navy); }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* App Wrapper */
.app-wrapper {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    position: relative;
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

@media (min-width: 900px) {
    .app-wrapper {
        max-width: 900px;
        display: grid;
        grid-template-columns: 240px 1fr;
        padding-bottom: 16px;
    }
    .desktop-sidebar { display: flex; }
    .bottom-nav { display: none !important; }
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
    color: var(--white);
    min-height: var(--top-bar-height);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.1rem;
}

.group-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.group-tagline {
    font-size: 0.7rem;
    opacity: 0.85;
    font-weight: 300;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    color: var(--white);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover, .icon-btn:focus {
    background: rgba(255,255,255,0.2);
    outline: none;
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--red);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 2px solid rgba(255,196,0,0.5);
    background: var(--blue);
    overflow: hidden;
    cursor: pointer;
    padding: 0;
}

.user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--gold);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    padding: 16px;
}

/* Welcome */
.welcome-text {
    margin-bottom: 16px;
}

.welcome-text h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
}

.welcome-text p {
    font-size: 0.85rem;
    color: var(--gray);
}

/* Financial Card */
.financial-card {
    background: linear-gradient(145deg, var(--navy) 0%, var(--blue) 60%, #1a4ab8 100%);
    border-radius: var(--radius);
    padding: 20px;
    color: var(--white);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.financial-card::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: rgba(255,196,0,0.12);
    border-radius: 50%;
}

.financial-card .label {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-bottom: 4px;
}

.financial-card .balance {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 16px;
    color: var(--gold);
}

.financial-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.fin-stat {
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.fin-stat .stat-label {
    font-size: 0.7rem;
    opacity: 0.8;
}

.fin-stat .stat-value {
    font-size: 0.95rem;
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--gold-dark);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
}

.quick-action:active {
    transform: scale(0.96);
}

.quick-action .qa-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--white);
}

.qa-icon.members { background: linear-gradient(135deg, #10338A, #081D5C); }
.qa-icon.contrib { background: linear-gradient(135deg, #10B981, #059669); }
.qa-icon.loan { background: linear-gradient(135deg, #F59E0B, #D97706); }
.qa-icon.trans { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }

.quick-action span {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
}

/* Stat boxes */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-box .stat-label {
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 4px;
}

.stat-box .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--navy);
}

.stat-box .stat-sub {
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 2px;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-dark));
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* List items */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.list-item-body { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-sub {
    font-size: 0.75rem;
    color: var(--gray);
}

.list-item-right {
    text-align: right;
    flex-shrink: 0;
}

.list-item-amount {
    font-weight: 600;
    font-size: 0.9rem;
}

.list-item-amount.positive { color: var(--green); }
.list-item-amount.negative { color: var(--red); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-secondary { background: #F1F5F9; color: #475569; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--navy), var(--blue));
    color: var(--white);
}

.btn-primary:hover { filter: brightness(1.08); color: var(--white); }

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--navy);
    font-weight: 600;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn-link {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(16, 51, 138, 0.12);
}

.form-control.is-invalid {
    border-color: var(--red);
}

.invalid-feedback {
    font-size: 0.75rem;
    color: var(--red);
    margin-top: 4px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--gray);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--gray);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
}

/* Loading */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* Flash / Alerts */
.flash-container {
    padding: 12px 16px 0;
}

.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error { background: #FEE2E2; color: #991B1B; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-info { background: #DBEAFE; color: #1E40AF; }

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    color: inherit;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 8px;
    color: var(--gray);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 500;
    min-width: 56px;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item.active {
    color: var(--navy);
}

.nav-item.active i {
    color: var(--gold-dark);
}

/* Desktop sidebar */
.desktop-sidebar {
    display: none;
    flex-direction: column;
    background: var(--navy);
    color: white;
    padding: 20px 0;
    min-height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 12px;
}

.sidebar-header strong { display: block; font-size: 0.95rem; }
.sidebar-header small { opacity: 0.7; font-size: 0.75rem; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--gold);
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
}
