/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    color: #2d3748;
    line-height: 1.5;
}

#app {
    min-height: 100vh;
}

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #1a202c;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
}

/* Cards and containers */
.upload-section,
.image-section,
.participants-section,
.bill-details-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

/* Upload section */
.upload-options {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* Legacy upload area styles removed in favor of shadcn components */

/* Legacy action sheet styles removed */

/* Webcam interface */
.webcam-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.webcam-overlay.active {
    opacity: 1;
}

.webcam-container {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90%;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.webcam-overlay.active .webcam-container {
    transform: scale(1);
}

.webcam-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.webcam-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

.webcam-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #718096;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webcam-video-container {
    position: relative;
    background: #000;
}

#webcamVideo {
    width: 100%;
    height: auto;
    display: block;
}

.webcam-controls {
    padding: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Device-specific styles */
/* Legacy device-specific upload styles removed */

/* Legacy file input (hidden) */
#fileInput {
    display: none;
}

/* Legacy button styles removed; shadcn components provide styling */

/* Image section */
.image-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.image-controls {
    display: flex;
    gap: 8px;
}

.image-preview {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    background: #f7fafc;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

.image-preview.collapsed img {
    max-height: 150px;
}

/* Summary container */
.summary-container {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 20px;
}

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

.participants-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.participant-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.participant-name {
    font-weight: 500;
    color: #2d3748;
}

.participant-amount {
    font-weight: 600;
    color: #1a202c;
}

/* Participants section */
.participants-manager {
    margin-top: 16px;
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    min-width: 0; /* Allow flex items to shrink */
}

.participant-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    min-width: 0; /* Allow input to shrink */
    word-wrap: break-word;
    order: 1; /* Position first when visible */
}

.participant-amount {
    font-weight: 600;
    color: #2d3748;
    min-width: 80px;
    text-align: right;
    font-size: 14px;
    flex-shrink: 0; /* Don't shrink the amount */
    word-wrap: break-word;
    order: 3; /* Always position at the end */
}

.participant-name-display {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    color: #2d3748;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 0;
    word-wrap: break-word;
    order: 1; /* Position first */
}

.participant-name-display:hover {
    background: #f7fafc;
    border-color: #e2e8f0;
}

.participant-delete {
    display: none;
    order: 2; /* Position after name but before amount */
}

.participant-row:hover .participant-delete {
    display: block;
}

.add-participant-row {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f7fafc;
    border: 1px dashed #cbd5e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 8px 0;
}

.add-participant-row:hover {
    background: #edf2f7;
    border-color: #a0aec0;
}

.add-participant-text {
    color: #718096;
    font-size: 14px;
    font-weight: 500;
}

.standalone-participants h4 {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
}

.summary-placeholder {
    color: #718096;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Bill details */
.establishment-info {
    margin-bottom: 24px;
    padding: 16px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.establishment-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 8px;
}

.establishment-info p {
    color: #718096;
    font-size: 14px;
}

.establishment-address {
    color: #4a5568;
    font-size: 13px;
    margin: 4px 0;
}

.establishment-phone,
.establishment-website {
    color: #4a5568;
    font-size: 13px;
    margin: 2px 0;
}

.establishment-other {
    color: #718096;
    font-size: 12px;
    margin: 2px 0;
    font-style: italic;
}

/* Line items */
.line-items {
    margin: 24px 0;
}

.line-item {
    margin: 12px 0;
    padding: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.item-name {
    font-weight: 500;
    color: #2d3748;
}

.item-price {
    font-weight: 600;
    color: #1a202c;
}

.item-assignment {
    margin-top: 12px;
}

.assignment-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    background: #edf2f7;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

.split-amount {
    font-weight: 500;
    color: #4a5568;
    font-size: 13px;
    margin-top: 8px;
}

/* Taxes and surcharges */
.taxes-section,
.surcharges-section {
    margin: 20px 0;
    padding: 16px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.tax-item,
.surcharge-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.tax-item:last-child,
.surcharge-item:last-child {
    border-bottom: none;
}

/* Tip input row */
.tip-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-weight: 500;
}

.tip-label {
    min-width: 30px;
}

.tip-currency {
    font-weight: 600;
    color: #2d3748;
}

.tip-input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    text-align: right;
}

/* Remove spinner arrows from number input */
.tip-input::-webkit-outer-spin-button,
.tip-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tip-input[type=number] {
    -moz-appearance: textfield;
}

/* Totals */
.totals-section {
    margin: 20px 0;
    padding: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.subtotal,
.total {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-weight: 500;
}

.total {
    border-top: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 16px;
    color: #1a202c;
}

/* Loading and error states */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
    font-size: 14px;
}

.error {
    text-align: center;
    padding: 20px;
    color: #c53030;
    background: #fed7d7;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    margin: 16px 0;
    font-size: 14px;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 16px;
    }
    
    .nav-menu {
        display: none;
    }
    
    .main-content {
        padding: 24px 16px;
    }
    
    .image-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .upload-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .image-controls {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .assignment-checkboxes {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .nav-container {
        height: 56px;
    }
    
    .brand-text {
        display: none;
    }
    
    .image-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .participant {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .participant-total {
        text-align: left;
    }
}