/* SPLTTR - Mobile-First Styles */

:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --secondary: #6B7280;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --error: #EF4444;
    --success: #10B981;
    --warning: #F59E0B;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    
    --radius: 12px;
    --radius-lg: 20px;
    
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.screen.active {
    display: flex;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

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

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

.btn-primary:hover, .btn-primary:active {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:active {
    background: var(--background);
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
    width: 100%;
}

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

/* Loading Screen */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content .logo {
    font-size: 64px;
    margin-bottom: 16px;
}

.loading-content h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 24px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.spinner.large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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

/* Home Screen */
.home-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.hero {
    text-align: center;
    padding: 40px 0;
}

.hero h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.hero p {
    color: var(--text-muted);
    font-size: 16px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-section {
    text-align: center;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.auth-section p {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.auth-section.hidden {
    display: none;
}

/* Avatar */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar.large {
    width: 80px;
    height: 80px;
}

.avatar.hidden {
    display: none;
}

#profile-icon {
    font-size: 24px;
}

/* Scan Screen */
.scan-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.scan-prompt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    gap: 16px;
}

.scan-prompt.hidden {
    display: none;
}

.scan-icon {
    font-size: 64px;
    margin-bottom: 8px;
}

.scan-prompt h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.scan-prompt p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.scan-prompt .btn {
    width: 100%;
    max-width: 280px;
}

.scan-preview {
    position: absolute;
    inset: 0;
    background: var(--surface);
    display: flex;
    flex-direction: column;
}

.scan-preview.hidden {
    display: none;
}

#preview-image {
    flex: 1;
    object-fit: contain;
    background: #000;
}

.preview-actions {
    display: flex;
    gap: 12px;
    padding: 16px;
}

.preview-actions .btn {
    flex: 1;
}

/* Processing Screen */
#processing-screen {
    justify-content: center;
    align-items: center;
}

.processing-content {
    text-align: center;
    padding: 24px;
}

.processing-content h2 {
    margin: 24px 0 8px;
}

.processing-content p {
    color: var(--text-muted);
}

/* Bill Screen */
.bill-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.participants-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.participant-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--background);
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
}

.participant-chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.participant-chip.owner {
    border: 2px solid var(--primary);
}

.items-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.item-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.item-card:active {
    transform: scale(0.98);
}

.item-card.claimed {
    border-left: 4px solid var(--text);
}

.item-card.claimed-by-me {
    border-left-color: var(--primary);
    background: #ECFDF5;
}

.item-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.item-card.claimed .item-checkbox {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.item-checkbox::after {
    content: '✓';
    display: none;
}

.item-card.claimed .item-checkbox::after {
    display: block;
}

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

.item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-claimer {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.item-price {
    font-weight: 600;
    color: var(--text);
}

/* Bill Summary */
.bill-summary {
    padding: 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 15px;
}

.tip-row {
    flex-direction: column;
    gap: 8px;
}

.tip-selector {
    display: flex;
    gap: 8px;
}

.tip-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tip-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.total-row {
    font-size: 18px;
    font-weight: 600;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
}

/* My Share */
.my-share {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    text-align: center;
}

.my-share h3 {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.share-amount {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
}

.my-share .btn {
    background: white;
    color: var(--primary);
}

/* Join Screen */
.join-main {
    flex: 1;
    padding: 24px;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.join-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 500;
}

.join-form input {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
}

.join-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding-bottom: calc(24px + var(--safe-bottom));
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal h2 {
    margin-bottom: 20px;
    text-align: center;
}

/* Share Modal */
.share-qr {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.share-qr canvas {
    border-radius: var(--radius);
}

.share-code {
    text-align: center;
    font-size: 18px;
    margin-bottom: 16px;
}

.share-link {
    display: flex;
    gap: 8px;
}

.share-link input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

/* Payment Modal */
.payment-amount {
    text-align: center;
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    margin: 16px 0;
}

.payment-qr {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#payment-recipient, #payment-method-text {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#payment-link {
    display: block;
    text-align: center;
    text-decoration: none;
    margin-top: 16px;
}

/* Profile Modal */
.profile-info {
    text-align: center;
    margin-bottom: 24px;
}

.profile-info h3 {
    margin-top: 12px;
}

.profile-info p {
    color: var(--text-muted);
}

.payment-settings h4 {
    margin-bottom: 12px;
}

.payment-options {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.payment-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.payment-option:has(input:checked) {
    border-color: var(--primary);
    background: #ECFDF5;
}

.payment-option input {
    display: none;
}

.payment-input {
    margin-bottom: 16px;
}

.payment-input.hidden {
    display: none;
}

.payment-input label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-input input {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
}

#logout-btn {
    width: 100%;
    margin-top: 16px;
    color: var(--error);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 200;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.error {
    background: var(--error);
}

.toast.success {
    background: var(--success);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (min-width: 480px) {
    .modal-content {
        max-width: 420px;
        margin: auto;
        border-radius: var(--radius-lg);
        margin-bottom: 20px;
    }
    
    .modal {
        align-items: center;
    }
}
