/* ============================================
   EXPENSE SHARING APP — MODERN REDESIGN 2025
   ============================================ */

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

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

:root {
    /* Brand */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-500: #4f46e5;
    --brand-600: #4338ca;
    --brand-700: #3730a3;
    --violet:    #7c3aed;

    /* Semantic */
    --success:        #22c55e;
    --success-bg:     #f0fdf4;
    --success-border: #bbf7d0;
    --danger:         #ef4444;
    --danger-bg:      #fef2f2;
    --danger-border:  #fecaca;
    --warning:        #f59e0b;
    --warning-bg:     #fffbeb;
    --warning-border: #fde68a;

    /* Neutrals */
    --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;

    /* Radii */
    --radius-sm:   8px;
    --radius-md:   14px;
    --radius-lg:   20px;
    --radius-xl:   28px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs:   0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm:   0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:   0 8px 30px rgba(0,0,0,0.12);
    --shadow-xl:   0 20px 60px rgba(0,0,0,0.18);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
    --shadow-btn:  0 4px 14px rgba(79, 70, 229, 0.35);
    --shadow-btn-hover: 0 6px 20px rgba(79, 70, 229, 0.45);
}

/* ============================================
   BASE
   ============================================ */

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
    background-color: #ede9fe;
    background-image:
        radial-gradient(ellipse at 20% 10%,  rgba(79, 70, 229, 0.12) 0, transparent 55%),
        radial-gradient(ellipse at 85% 85%,  rgba(124, 58, 237, 0.10) 0, transparent 55%);
    background-attachment: fixed;
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* ============================================
   HEADER
   ============================================ */

header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(79, 70, 229, 0.45);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
}

header h1 {
    color: white;
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    font-size: 0.9375rem;
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
    background: white;
    border-radius: var(--radius-lg);
    margin: 1.25rem 0;
    box-shadow: var(--shadow-card);
    border: 1.5px solid var(--gray-200);
    overflow: hidden;
}

.navbar ul {
    list-style: none;
    display: flex;
    padding: 0.375rem;
    gap: 0.25rem;
}

.navbar li { flex: 1; }

.navbar a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--gray-500);
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.navbar a:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.navbar a.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: var(--shadow-btn);
}

@media (max-width: 768px) {
    .navbar ul { padding: 0.25rem; gap: 0.125rem; }
    .navbar a  { padding: 0.625rem 0.375rem; font-size: 0.8125rem; }
}

@media (max-width: 380px) {
    .navbar a { font-size: 0.75rem; padding: 0.5rem 0.25rem; }
}

/* ============================================
   MAIN CONTENT
   ============================================ */

main {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: 1.5px solid var(--gray-200);
    margin-bottom: 2rem;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 600px) {
    main { padding: 1rem; border-radius: var(--radius-lg); }
}

/* ============================================
   SECTIONS
   ============================================ */

section { margin-bottom: 2.5rem; }
section:last-child { margin-bottom: 0; }

section h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 2px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   BALANCE CARDS
   ============================================ */

.section-balances { margin-bottom: 2.5rem; }

.balances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.balance-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    cursor: default;
}

/* Decorative circle */
.balance-card::after {
    content: '';
    position: absolute;
    top: -24px;
    right: -24px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    pointer-events: none;
}

.balance-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.balance-card.positive {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.balance-card.negative {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.balance-card.neutral {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.balance-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    margin-bottom: 0.75rem;
    letter-spacing: 0.01em;
}

.balance-amount {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: white;
    margin-bottom: 0.375rem;
    line-height: 1.1;
}

.status-badge {
    display: inline-block;
    background: rgba(255,255,255,0.22);
    backdrop-filter: blur(4px);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
}

.balance-detail {
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 0.375rem;
    display: flex;
    justify-content: space-between;
}

.balance-detail strong {
    color: white;
    font-weight: 700;
}

@media (max-width: 768px) { .balances-grid { grid-template-columns: 1fr; } }

/* ============================================
   ADD PARTICIPANT FORM
   ============================================ */

.add-participant-form {
    background: var(--gray-50);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    border: 1.5px solid var(--gray-200);
}

.add-participant-form input[type="text"] {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    background: white;
    color: var(--gray-900);
    transition: all 0.2s ease;
}

.add-participant-form input[type="text"]:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.add-participant-form input[type="text"]::placeholder {
    color: var(--gray-400);
}

@media (max-width: 768px) {
    .add-participant-form { flex-direction: column; }
    .add-participant-form input[type="text"] { width: 100%; }
}

/* ============================================
   EXPENSE CARDS
   ============================================ */

.expenses-list {
    display: grid;
    gap: 1rem;
    margin-top: 1.25rem;
}

.expense-card {
    padding: 1.25rem 1.5rem;
    border: 1.5px solid var(--gray-100);
    border-radius: var(--radius-lg);
    background: white;
    transition: all 0.2s ease;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    position: relative;
    overflow: hidden;
}

.expense-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #4f46e5, #9333ea);
    border-radius: 4px 0 0 4px;
}

.expense-card:hover {
    border-color: var(--brand-100);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.expense-main { padding-left: 0.25rem; }

.expense-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.625rem;
    gap: 1rem;
}

.expense-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.expense-amount {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    padding: 0.3125rem 0.875rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9375rem;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    flex-shrink: 0;
}

.expense-paid-by {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.expense-paid-by strong {
    color: var(--gray-800);
    font-weight: 600;
}

.expense-participants {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--brand-500);
}

.expense-participants p {
    font-weight: 700;
    margin-bottom: 0.375rem;
    color: var(--gray-600);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.expense-participants ul { list-style: none; }

.expense-participants li {
    padding: 0.25rem 0;
    color: var(--gray-600);
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
}

.expense-date {
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin-bottom: 0.75rem;
}

.expense-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.875rem;
    border-top: 1.5px solid var(--gray-100);
}

.no-data {
    text-align: center;
    color: var(--gray-400);
    padding: 3rem;
    font-size: 0.9375rem;
}

@media (max-width: 768px) {
    .expense-card    { grid-template-columns: 1fr; }
    .expense-actions { flex-direction: column; }
    .expense-actions .btn-view,
    .expense-actions .btn-delete { width: 100%; }
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary,
.btn-view,
.btn-delete,
.btn-download,
.btn-back,
.btn-logout,
.btn-secondary {
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-family: inherit;
    letter-spacing: 0.01em;
    padding: 0.625rem 1.25rem;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-btn);
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    font-weight: 700;
}

.btn-primary:hover {
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-view {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    flex: 1;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-view:hover {
    filter: brightness(1.06);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.38);
}

.btn-delete {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1.5px solid var(--danger-border);
    flex: 1;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-download {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.32);
}

.btn-download:hover {
    filter: brightness(1.06);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.42);
}

.btn-copy-promptpay {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.35);
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.btn-copy-promptpay:hover {
    filter: brightness(1.06);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}

.btn-back {
    background: rgba(255,255,255,0.18);
    color: white;
    border: 1.5px solid rgba(255,255,255,0.35);
    backdrop-filter: blur(8px);
    font-size: 0.875rem;
}

.btn-back:hover { background: rgba(255,255,255,0.28); }

.btn-logout {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1.5px solid rgba(239, 68, 68, 0.25);
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ============================================
   FORMS
   ============================================ */

.form-expense {
    display: grid;
    gap: 1.25rem;
    max-width: 640px;
    width: 100%;
}

.auth-box .form-expense { max-width: 100%; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 700;
    color: var(--gray-700);
    font-size: 0.9375rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-family: inherit;
    background: white;
    color: var(--gray-900);
    transition: all 0.2s ease;
    min-width: 0;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 0;
}

.form-group input[type="file"]:hover {
    border-color: var(--brand-500);
    background: var(--brand-50);
    color: var(--brand-500);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--gray-400); }

.form-group small {
    color: var(--gray-400);
    font-size: 0.8125rem;
}

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

@media (max-width: 768px) {
    .form-expense { max-width: 100%; }
    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group input[type="file"],
    .form-group textarea,
    .form-group select { font-size: 1rem; } /* prevent iOS zoom */
}

/* ============================================
   PARTICIPANTS LIST
   ============================================ */

.participants-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
    width: 100%;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1.5px solid var(--gray-200);
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--gray-700);
    user-select: none;
    min-width: 0;
    word-break: break-word;
}

.checkbox-label:hover {
    border-color: var(--brand-500);
    background: var(--brand-50);
    color: var(--brand-500);
}

.checkbox-label:has(input:checked) {
    background: var(--brand-50);
    border-color: var(--brand-500);
    color: var(--brand-600);
    font-weight: 700;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--brand-500);
    flex-shrink: 0;
}

@media (max-width: 600px)  { .participants-list { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px)  { .participants-list { grid-template-columns: 1fr; } }

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: 1.5px solid;
}

.alert-error   { background: var(--danger-bg);  color: #b91c1c; border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: #15803d; border-color: var(--success-border); }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: var(--warning-border); }

/* ============================================
   AUTH PAGES
   ============================================ */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
    background-attachment: fixed;
}

.auth-box {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.35s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-box h1 {
    color: var(--brand-500);
    text-align: center;
    margin-bottom: 0.375rem;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.auth-box h2 {
    color: var(--gray-900);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.auth-link {
    text-align: center;
    margin-top: 1.25rem;
    color: var(--gray-500);
    font-size: 0.9375rem;
}

.auth-link a {
    color: var(--brand-500);
    text-decoration: none;
    font-weight: 700;
}

.auth-link a:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .auth-box { padding: 1.75rem; }
}

/* ============================================
   DETAIL PAGE
   ============================================ */

.detail-card {
    background: var(--gray-50);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    border: 1.5px solid var(--gray-200);
}

.detail-card h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 800;
}

.detail-amount, .detail-paid-by, .detail-date {
    margin-bottom: 0.75rem;
    color: var(--gray-700);
    font-size: 0.9375rem;
}

.detail-amount strong, .detail-paid-by strong, .detail-date strong {
    color: var(--brand-500);
    font-weight: 700;
}

.participants-detail, .bills-section { margin-bottom: 1.5rem; }

.participants-detail h3, .bills-section h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table th, .detail-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.detail-table th {
    background: var(--gray-50);
    font-weight: 700;
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-table tr:hover td { background: var(--gray-50); }

/* ============================================
   BILLS GALLERY
   ============================================ */

.bills-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bill-image {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: zoom-in;
    position: relative;
}

.bill-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.bill-image:hover img {
    transform: scale(1.06);
}

.bill-image:hover {
    box-shadow: var(--shadow-lg);
}

/* zoom icon overlay */
.bill-image::after {
    content: '🔍';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: var(--radius-md);
    pointer-events: none; /* ให้ click ทะลุผ่านไปถึง div จริง */
}

.bill-image:hover::after {
    opacity: 1;
}

/* ============================================
   LIGHTBOX (fullscreen image viewer)
   ============================================ */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    touch-action: pinch-zoom;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-img-wrap {
    position: relative;
    max-width: 94vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img-wrap img {
    max-width: 94vw;
    max-height: 86vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
    user-select: none;
    -webkit-user-drag: none;
    display: block;
}

/* ปุ่มปิด */
.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 10;
    backdrop-filter: blur(6px);
}
.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.1);
}

/* ปุ่ม prev / next */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 1.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    backdrop-filter: blur(6px);
    z-index: 10;
}
.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-50%) scale(1.08);
}
.lightbox-prev { left: 0.75rem; }
.lightbox-next { right: 0.75rem; }
.lightbox-nav.hidden { display: none; }

/* counter เล็กๆ ด้านล่าง */
.lightbox-counter {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full);
    backdrop-filter: blur(6px);
    letter-spacing: 0.05em;
}

/* ปุ่ม download ใน lightbox */
.lightbox-download {
    position: fixed;
    bottom: 1.25rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    backdrop-filter: blur(6px);
    transition: all 0.15s ease;
    font-family: inherit;
    cursor: pointer;
}
.lightbox-download:hover {
    background: rgba(255, 255, 255, 0.28);
    color: white;
}

/* ============================================
   SETTLEMENT PAGE
   ============================================ */

.settlement-card {
    background: var(--gray-50);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--gray-200);
    margin-bottom: 1rem;
}

.settlement-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-500);
}

.transfer-section { margin-top: 2rem; }

.transfer-section h3 {
    color: var(--gray-900);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    padding-bottom: 0.875rem;
    border-bottom: 2px solid var(--gray-100);
}

.transfer-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.125rem 1.5rem;
    background: white;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--gray-200);
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.transfer-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: #fecaca;
    transform: translateY(-1px);
}

.transfer-from, .transfer-to { flex: 1; }

.transfer-from .transfer-name {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--danger);
}

.transfer-to .transfer-name {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--success);
}

.transfer-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.transfer-middle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 110px;
}

.transfer-arrow { font-size: 1.25rem; color: var(--gray-300); }

.transfer-amount {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--gray-900);
    white-space: nowrap;
    letter-spacing: -0.025em;
}

/* Balance card กดได้ (สำหรับคนต้องจ่าย) */
.balance-card.card-payable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.balance-card.card-payable:hover {
    transform: translateY(-5px) scale(1.015);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}
.balance-card.card-payable:active {
    transform: scale(0.97);
}
.card-tap-hint {
    margin-top: 0.875rem;
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    text-align: center;
    letter-spacing: 0.01em;
    animation: pulseFade 2.5s ease-in-out infinite;
}
@keyframes pulseFade {
    0%, 100% { opacity: 0.75; }
    50%       { opacity: 1; }
}

/* ปุ่มจ่ายเงินบน transfer card */
.btn-pay {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    padding: 0.5rem 1.125rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-pay:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}
.btn-pay:active { transform: scale(0.97); }

@media (max-width: 520px) {
    .transfer-card {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    .transfer-from, .transfer-to { text-align: center; }
    .transfer-arrow { transform: rotate(90deg); }
    .transfer-middle { flex-direction: row-reverse; gap: 0.75rem; }
    .btn-pay { width: 100%; padding: 0.625rem; }
}

/* ============================================
   PAYMENT MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.75rem 1.5rem 1.5rem;
    width: 100%;
    max-width: 360px;
    position: relative;
    transform: scale(0.9) translateY(24px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
    flex-shrink: 0;
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-900); }

.modal-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
    text-align: center;
    padding-right: 2rem;
}

.modal-transfer-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    text-align: center;
    border: 1.5px solid var(--gray-100);
}

.modal-from {
    font-weight: 700;
    color: var(--danger);
    font-size: 0.9375rem;
}
.modal-to {
    font-weight: 700;
    color: var(--success);
    font-size: 0.9375rem;
}
.modal-amount {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--brand-500);
    background: var(--brand-50);
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
    border: 1.5px solid rgba(79, 70, 229, 0.2);
}
.modal-arrow { color: var(--gray-300); font-size: 1rem; }

.modal-qr {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}
.modal-qr img {
    width: 100%;
    max-width: 260px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--gray-100);
    box-shadow: var(--shadow-md);
    display: block;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}
.modal-actions .btn-download,
.modal-actions .btn-copy-promptpay,
.modal-actions .btn-secondary {
    width: 100%;
    padding: 0.875rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.modal-actions .btn-copy-promptpay {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

.modal-actions .btn-copy-promptpay:hover,
.modal-actions .btn-copy-promptpay:active {
    filter: brightness(1.08);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
}
.modal-actions .btn-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    font-family: inherit;
    border: 1.5px solid var(--gray-200);
}
.modal-actions .btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

/* ============================================
   SELECT ALL BUTTONS
   ============================================ */

.select-all-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.btn-select-all, .btn-select-none {
    padding: 0.375rem 0.875rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-full);
    background: white;
    color: var(--gray-600);
    font-size: 0.8125rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.15s ease;
}

.btn-select-all:hover {
    background: var(--brand-500);
    color: white;
    border-color: var(--brand-500);
}

.btn-select-none:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

/* ============================================
   SPLIT PREVIEW
   ============================================ */

.split-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(124, 58, 237, 0.04));
    border: 1.5px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--radius-md);
    margin-top: 0.875rem;
    color: var(--gray-600);
    font-size: 0.9375rem;
    animation: fadeSlideIn 0.25s ease;
}

.split-preview strong {
    color: var(--brand-500);
    font-size: 1.125rem;
    font-weight: 800;
}

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

/* ============================================
   IMAGE PREVIEW
   ============================================ */

.image-preview-container {
    margin-top: 0.875rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--gray-200);
    background: var(--gray-50);
}

.image-preview-container img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.hidden      { display: none !important; }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.gap-sm      { gap: 0.5rem; }
.gap-md      { gap: 1rem; }
.gap-lg      { gap: 1.5rem; }
.mt-0  { margin-top: 0; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mt-xl { margin-top: 2rem; }
.mb-0  { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mb-xl { margin-bottom: 2rem; }
