/* ==========================================================================
   MoneyBalice - Pro Light Theme & Mobile-First CSS
   Compatible with PHP MVC, Mobile Responsive, Bottom Sheet & Bottom Nav
   ========================================================================== */

:root {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    
    --accent-green: #10b981;
    --accent-green-light: #ecfdf5;
    --accent-pink: #ec4899;
    --accent-pink-light: #fdf2f8;
    --accent-amber: #f59e0b;
    --accent-amber-light: #fffbe6;
    --accent-purple: #8b5cf6;
    --accent-danger: #ef4444;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.08);
    --shadow-sheet: 0 -10px 40px rgba(15, 23, 42, 0.12);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 9999px;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: 90px; /* Space for bottom nav */
}

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

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

.app-wrapper {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--bg-primary);
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.03);
}

/* Top Navigation Bar */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}

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

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: var(--border-light);
}

.icon-btn-sm {
    background: var(--border-light);
    border: none;
    border-radius: var(--radius-pill);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-main);
}

.brand-icon {
    font-size: 1.35rem;
}

.brand-accent {
    color: var(--primary);
}

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

.family-badge {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.avatar-lg {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-pill);
    color: #ffffff;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Off-canvas Side Drawer */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 320px;
    background: var(--bg-card);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.side-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-light);
}

.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-user-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
}

.drawer-user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.drawer-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.drawer-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.drawer-item-danger {
    color: var(--accent-danger);
}

.drawer-item-danger:hover {
    background-color: #fef2f2;
}

.drawer-icon {
    font-size: 1.25rem;
}

.drawer-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 8px;
}

/* Main Container */
.main-container {
    padding: 18px 16px;
}

/* Fixed Mobile Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: 72px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 90;
    padding: 0 8px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-light);
    font-size: 0.72rem;
    font-weight: 600;
    flex: 1;
    transition: color 0.2s, transform 0.2s;
}

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

.nav-item:active {
    transform: scale(0.92);
}

/* Prominent Raised FAB Button in Center of Bottom Nav */
.nav-fab-btn {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
    margin-top: -24px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

.nav-fab-btn:active {
    transform: scale(0.9) translateY(4px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Pro Bottom Sheet Modal ("Panel che arriva da sotto") */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sheet-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 600px;
    max-height: 92vh;
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 301;
    box-shadow: var(--shadow-sheet);
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bottom-sheet.open {
    transform: translate(-50%, 0);
}

.sheet-handle-wrapper {
    padding: 10px 0 4px;
    display: flex;
    justify-content: center;
    cursor: grab;
}

.sheet-handle {
    width: 42px;
    height: 5px;
    border-radius: var(--radius-pill);
    background-color: var(--border-color);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 14px;
    border-bottom: 1px solid var(--border-light);
}

.sheet-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
}

.sheet-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Amount Hero Input */
.amount-hero-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-green-light);
    border: 2px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-lg);
    padding: 16px;
    gap: 6px;
}

.currency-symbol {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-green);
}

.amount-hero-input {
    border: none;
    background: transparent;
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--text-main);
    width: 180px;
    text-align: left;
    outline: none;
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #ffffff;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Category Pill Selector Grid */
.category-pill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
    padding: 2px;
}

.cat-pill input[type="radio"] {
    display: none;
}

.cat-pill-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.cat-pill input[type="radio"]:checked + .cat-pill-inner {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.cat-icon {
    font-size: 1.1rem;
}

.cat-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Segmented Control for Paid By Member */
.segmented-control {
    display: flex;
    background: var(--border-light);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.segment-item {
    flex: 1;
}

.segment-item input[type="radio"] {
    display: none;
}

.segment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.segment-item input[type="radio"]:checked + .segment-btn {
    background: #ffffff;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.member-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-pill);
}

/* File Upload Box */
.file-upload-box {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    background: var(--bg-primary);
    transition: border-color 0.2s;
}

.file-upload-box:hover {
    border-color: var(--primary);
}

.file-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--border-light);
    color: var(--text-main);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 15px 24px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

/* Dashboard Summary Cards */
.dash-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

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

.card-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);

}

.hero-total-card {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.hero-total-amount {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin: 6px 0;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Member Breakdown Cards */
.member-spending-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.member-spending-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.member-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.member-amount {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

/* Settlement Balance Banner ("Chi deve dare a chi") */
.settlement-banner {
    background: var(--accent-amber-light);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.settlement-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: #b45309;
    margin-bottom: 6px;
}

.settlement-text {
    font-size: 0.9rem;
    color: #92400e;
    font-weight: 500;
}

/* Expense Items List */
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0 12px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

.expense-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.expense-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

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

.expense-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.expense-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.expense-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.expense-right {
    text-align: right;
}

.expense-amount-val {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
}

.expense-by-user {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Auth Login Screen */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

.auth-card {
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 8px;
}

.alert-danger {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* Funny Bancomat Alert Banner ("Hai strisciato troppo!") */
.funny-bancomat-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 9999;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: 0 14px 30px rgba(220, 38, 38, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.funny-bancomat-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    animation: wiggle 0.5s ease-in-out 0.4s;
}

/* Detailed Custom Delete Confirmation Modal */
.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 440px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    z-index: 401;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.custom-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
}

.custom-modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-danger);
}

.custom-modal-body {
    padding: 20px;
}

.delete-details-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delete-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
}

.delete-detail-label {
    color: var(--text-muted);
}

.delete-detail-value {
    font-weight: 700;
    color: var(--text-main);
}

.custom-modal-footer {
    padding: 14px 20px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-primary);
}

.btn-danger-custom {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger-custom:hover {
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.4);
}
