/* Receipt Splitter Styles */

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
    background-color: #f8f9fa;
    min-height: 100vh;
}

/* Page container */
.page {
    min-height: 100vh;
    background-color: #f8f9fa;
    padding-bottom: 100px; /* Space for fixed buttons */
}

.container {
    background: white;
    padding: 24px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 20px 16px;
}

@media (max-width: 480px) {
    .container {
        margin: 16px 12px;
    }
}


h1 {
    text-align: center;
    color: #333;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 28px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

@media (min-width: 480px) {
    .input-group {
        flex-direction: row;
    }
}

input[type="text"] {
    flex: 1;
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    min-height: 20px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #007bff;
}

button {
    padding: 16px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 20px;
    touch-action: manipulation;
}

@media (min-width: 480px) {
    button {
        padding: 12px 24px;
    }
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 12px;
    display: none;
    font-size: 14px;
    line-height: 1.4;
}

.error.show {
    display: block;
}

/* Initial Friends Section */
.initial-friends-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.initial-friends-section h3 {
    margin: 0 0 20px 0;
    color: #495057;
    font-size: 18px;
    font-weight: 600;
}

.initial-friends-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.initial-friend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.initial-friend-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.initial-friend-name {
    font-size: 16px;
    color: #495057;
    font-weight: 500;
}

.initial-friend-delete {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    padding: 0;
}

.initial-friend-delete img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.initial-friend-delete:hover {
    background-color: #c82333;
}

.add-friend-btn-initial {
    width: 100%;
    padding: 12px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-friend-btn-initial:hover {
    background-color: #218838;
}

/* Receipt Display Styles */
#receiptPage {
    padding: 20px 16px 0 16px;
    padding-bottom: 180px; /* Space for friends section with done button */
}

.receipt-container {
    background: white;
    padding: 24px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    max-width: 600px;
}

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

.receipt-header h2 {
    margin: 0;
    color: #333;
    font-weight: 600;
}

#backBtn {
    background-color: #6c757d;
    padding: 8px 16px;
    font-size: 14px;
}

#backBtn:hover {
    background-color: #5a6268;
}

.receipt-content {
    font-family: 'Lato', sans-serif;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Floating Friends Section */
.friends-section {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    /* height: 20vh;     */
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 4px 16px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    padding: 0px 16px 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.friends-section-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #666;
    text-align: center;
}

.friends-container {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    flex: 1;
    min-height: 0;
}

.friends-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.friend-square {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: 2px solid transparent;
    padding: 4px;
}

.friend-name {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

.friend-amount {
    font-size: 10px;
    font-weight: 400;
    color: #000;
    margin-top: 2px;
    line-height: 1;
}

.friend-square:hover {
    transform: scale(1.05);
}

.friend-square.active {
    border: 2px solid #565656;
    /* transform: scale(1.05); */
}

.friend-square.me {
    background-color: #e3f2fd;
}

.friend-square.me.active {
    border: 2px solid #565656;
}

.friend-square.friend {
    background-color: #f3e5f5;
}

.add-friend-btn {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background-color: #f5f5f5;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

.add-friend-btn:hover {
    background-color: #e0e0e0;
    border-color: #999;
}

.delete-overlay {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background-color: #666;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    cursor: pointer;
    z-index: 1001;
    transition: background-color 0.2s ease;
}

.delete-overlay:hover {
    background-color: #ff4444;
}

/* Pastel color variations */
.friend-square.friend:nth-child(2) { background-color: #e8f5e8; }
.friend-square.friend:nth-child(3) { background-color: #fff3e0; }
.friend-square.friend:nth-child(4) { background-color: #fce4ec; }
.friend-square.friend:nth-child(5) { background-color: #e0f2f1; }
.friend-square.friend:nth-child(6) { background-color: #f1f8e9; }
.friend-square.friend:nth-child(7) { background-color: #fff8e1; }
.friend-square.friend:nth-child(8) { background-color: #f3e5f5; }
.friend-square.friend:nth-child(9) { background-color: #e3f2fd; }
.friend-square.friend:nth-child(10) { background-color: #e8eaf6; }

/* Receipt item row styles */
.receipt-item-row {
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #e7e7e7;
    border: 1px solid #ddd;
    border-left: 3px solid #007bff;
    background-color: #ffffff;
    position: relative;
}

.receipt-content table {
    border-spacing: 0 10px;
    border-collapse: separate;
}

/* More specific selectors to ensure padding applies */
tr.receipt-item-row {
    padding: 10px 8px !important;
    
}

tr.receipt-item-row td {
    padding: 10px 8px !important;
    vertical-align: top;
}

/* Apply border-radius to the first and last cells for rounded corners */
tr.receipt-item-row td:first-child {
    position: relative;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    border-left: 1px solid #cfcfcf;
    border-top: 1px solid #cfcfcf;
    border-bottom: 1px solid #cfcfcf;
}

tr.receipt-item-row td:last-child {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    border-right: 1px solid #cfcfcf;
    border-top: 1px solid #cfcfcf;
    border-bottom: 1px solid #cfcfcf;
}


.receipt-summary-row {
    cursor: default;
}

/* Clean table styling */
.receipt-item-row td,
.receipt-summary-row td {
    padding: 5px 8px;
    border: none;
}

/* Item selection styles - darker blue when selected */
.item-selected {
    background-color: #f0f0f0 !important;
}

/* Name chips container and chips */
.name-chips-container {
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding-bottom: 2px;
}

.name-chips-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.name-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
}

/* Items selected by the active friend - thicker blue border */
tr.receipt-item-row.selected-by-active td:first-child{
    font-weight: bold;
    background-color: #e9f5ff !important;
    border-left: 1px solid #000000 !important;
    border-top: 1px solid #000000 !important;
    border-bottom: 1px solid #000000 !important;
}

tr.receipt-item-row.selected-by-active td:last-child {
    font-weight: bold;
    background-color: #e9f5ff !important;
    border-right: 1px solid #000000 !important;
    border-top: 1px solid #000000 !important;
    border-bottom: 1px solid #000000 !important;
    
}

@media (max-width: 480px) {
    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    .error {
        font-size: 13px;
        padding: 10px 14px;
    }

    .receipt-container {
        padding: 16px 12px;
        margin: 0 8px;
        border-radius: 8px;
    }

    .receipt-content {
        padding: 0;
        font-size: 14px;
    }

    .receipt-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .receipt-header h2 {
        font-size: 20px;
        margin: 0;
        flex: 1;
        text-align: left;
        line-height: 1.2;
    }

    #backBtn {
        padding: 12px 20px;
        font-size: 16px;
        min-width: 80px;
        flex-shrink: 0;
        border-radius: 8px;
        font-weight: 500;
    }

    .friends-section {
        width: 100%;
        bottom: 0;
        /* height: 20vh; */
        border-radius: 16px 16px 0 0;
    }
    
    #receiptPage {
        padding-bottom: 180px;
    }

    /* Extra small screens */
    @media (max-width: 360px) {
        .receipt-header h2 {
            font-size: 18px;
        }

        #backBtn {
            padding: 10px 16px;
            font-size: 14px;
            min-width: 70px;
        }

        .receipt-container {
            padding: 12px 8px;
            margin: 0 4px;
        }
    }

    .friend-square, .add-friend-btn {
        width: 50px;
        height: 50px;
        font-size: 12px;
    }
}

/* Friends Page Styles */
.back-button {
    background: none;
    border: none;
    color: #495057;
    font-size: 16px;
    font-weight: 500;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.back-button:hover {
    color: #333;
}

.friends-page-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 24px;
    max-width: 600px;
    margin: 0 auto;
}

.friends-icon {
    margin-bottom: 24px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.friends-icon img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.friends-page-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    text-align: center;
}

.friends-page-subtitle {
    font-size: 16px;
    color: #666;
    margin: 0 0 32px 0;
    text-align: center;
    font-weight: 400;
}

.friend-input-group {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 24px;
}

#friendNameInput {
    flex: 1;
    padding: 14px 16px;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    background: white;
    transition: border-color 0.2s ease;
}

#friendNameInput:focus {
    outline: none;
    border-color: #007bff;
}

.add-friend-button {
    width: 48px;
    height: 48px;
    background-color: #333;
    border: none;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.add-friend-button svg {
    width: 20px;
    height: 20px;
}

.add-friend-button svg path {
    stroke: white;
    stroke-width: 2.5;
}

.add-friend-button:hover:not(.disabled) {
    background-color: #000;
}

.add-friend-button.disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.add-friend-button.disabled svg path {
    stroke: #adb5bd;
}

.friends-list {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 100px; /* Space for fixed button */
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.friend-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.friend-card-name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.friend-card-delete {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #e9ecef;
    border: none;
    color: #495057;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}

.friend-card-delete:hover {
    background-color: #dee2e6;
}

.continue-friends-button-container {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    padding: 20px 24px;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    border-radius: 16px 16px 0 0;
}

.continue-friends-button {
    width: 90%;
    padding: 18px 40px;
    background-color: #1a1a1a;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    margin: 0 auto;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-sizing: border-box;
    display: block;
}

.continue-friends-button:hover {
    background-color: #000;
}

/* Done Button Styles (inside friends section) */
.done-button {
    width: 90%;
    padding: 18px 20px;
    background-color: #383838;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    margin: 16px auto 20px auto;
    cursor: pointer;
    box-sizing: border-box;
    display: block;
    flex-shrink: 0;
}

.done-button:hover {
    background-color: #212121;
}

@media (max-width: 480px) {
    .done-button {
        padding: 16px 32px;
        font-size: 15px;
        margin: 12px auto 16px auto;
    }
}

/* Summary Page Styles */
.summary-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 20px;
}

.summary-header-section {
    margin-bottom: 32px;
}

.summary-back-button {
    background: none;
    border: none;
    color: #495057;
    font-size: 16px;
    font-weight: 500;
    padding: 0 0 16px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
    margin-bottom: 8px;
}

.summary-back-button:hover {
    color: #333;
}

.summary-header {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

.summary-subtitle {
    text-align: center;
    font-size: 16px;
    color: #666;
    margin: 0 0 24px 0;
    font-weight: 400;
}

.share-split-section {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 32px;
}

.share-split-button {
    width: auto;
    min-width: 120px;
    height: 25px;
    padding: 0 20px;
    background-color: #1a1a1a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.share-split-button:hover {
    background-color: #000;
}

.summary-friends-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-friend-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.summary-friend-info-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.summary-friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.summary-friend-name-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-friend-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.summary-item-count {
    font-size: 14px;
    color: #666;
    font-weight: 400;
}

.summary-total-amount {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.summary-items-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.summary-items-label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    flex-shrink: 0;
    padding-top: 2px;
}

.summary-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.summary-item-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background-color: #f5f5f5;
    border-radius: 12px;
    font-size: 13px;
    color: #333;
    font-weight: 400;
}

.no-items-message {
    text-align: center;
    color: #666;
    font-size: 16px;
    padding: 40px 20px;
}

@media (max-width: 480px) {
    .summary-container {
        padding: 20px 16px;
    }
    
    .summary-back-button {
        padding: 0 0 12px 0;
        font-size: 15px;
    }
    
    .summary-header {
        font-size: 24px;
    }
    
    .summary-subtitle {
        font-size: 14px;
    }
    
    .share-split-section {
        margin-bottom: 24px;
    }
    
    .share-split-button {
        height: 25px;
        padding: 0 16px;
        font-size: 13px;
        min-width: 100px;
    }
    
    .summary-friend-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .friends-page-content {
        padding: 16px 20px;
    }
    
    .friends-page-title {
        font-size: 24px;
    }
    
    .friends-page-subtitle {
        font-size: 14px;
    }
    
    .friend-input-group {
        margin-bottom: 20px;
    }
    
    .friends-list {
        margin-bottom: 90px;
    }
    
    .continue-friends-button-container {
        padding: 16px 20px;
    }
    
    .continue-friends-button {
        padding: 16px 32px;
        font-size: 15px;
    }
}
