/* ===========================
   CSS Reset & Base Styles
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-First: Plain background, no decorative elements */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
}

/* ===========================
   Main Container
   =========================== */
/* Mobile-First: Full screen, no rounded corners, no shadows */
.container {
    background: white;
    width: 100%;
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ===========================
   Tabs
   =========================== */
/* Mobile-First: No rounded corners */
.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
}

.tab-btn {
    flex: 1;
    padding: 18px 20px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn.active {
    color: #667eea;
    background: white;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #667eea;
}

.tab-btn:hover:not(.active) {
    background: #eeeff1;
}

/* ===========================
   Budget Display
   =========================== */
.budget-display {
    padding: 20px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    border-bottom: 1px solid #e0e0e0;
}

/* ===========================
   Gift List
   =========================== */
.gift-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(100px + env(safe-area-inset-bottom)); /* Space for bottom nav + safe area */
}

.gift-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    user-select: none;
}

.gift-card:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
    transform: translateY(-2px);
}

.gift-card:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.gift-card.purchased {
    opacity: 0.5;
    background: #f8f9fa;
}

.gift-info {
    flex: 1;
}

.gift-product {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.gift-card.purchased .gift-product {
    text-decoration: line-through;
}

.gift-person {
    font-size: 13px;
    color: #888;
}

.gift-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gift-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    min-width: 70px;
    text-align: right;
}

.open-btn {
    padding: 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.open-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
}

.open-btn:active {
    transform: scale(0.95);
}

.open-btn svg {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
}

/* ===========================
   Bottom Navigation
   =========================== */
/* Mobile-First: No rounded corners */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #e0e0e0;
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)); /* Add safe area for iPhone notch/home indicator */
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.nav-btn:active {
    transform: translateY(-1px);
}

.nav-btn svg {
    fill: white;
}

/* ===========================
   Modals
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 24px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 22px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===========================
   Form Elements
   =========================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Settings Info */
.settings-info {
    padding: 16px;
    background: #f0f2ff;
    border: 2px solid #c5d0ff;
    border-radius: 12px;
    margin-bottom: 24px;
}

.settings-info p {
    font-size: 14px;
    color: #555;
    margin-bottom: 12px;
    line-height: 1.5;
}

.settings-info p:last-child {
    margin-bottom: 0;
}

/* Settings Danger Zone */
.settings-divider {
    height: 2px;
    background: #e0e0e0;
    margin: 24px 0;
}

.settings-danger-zone {
    padding: 16px;
    background: #fff5f5;
    border: 2px solid #ffcdd2;
    border-radius: 12px;
}

.settings-danger-zone h3 {
    font-size: 16px;
    color: #dc3545;
    margin-bottom: 8px;
}

.settings-danger-zone p {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* ===========================
   Detail View
   =========================== */
.detail-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.detail-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-item strong {
    display: block;
    margin-bottom: 6px;
    color: #667eea;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item span {
    color: #333;
    font-size: 15px;
    word-break: break-word;
}

.checkbox-item {
    border: none;
}

.checkbox-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

.checkbox-item span {
    font-size: 15px;
    font-weight: 600;
}

/* ===========================
   Summary Modal
   =========================== */
.summary-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
}

.summary-header h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 8px;
}

.summary-total {
    font-size: 16px;
    color: #667eea;
}

.summary-total strong {
    font-size: 20px;
}

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

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.summary-person {
    flex: 1;
}

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

.summary-count {
    font-size: 13px;
    color: #888;
}

.summary-amount {
    text-align: right;
}

.summary-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 2px;
}

.summary-percentage {
    font-size: 12px;
    color: #888;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-danger:active {
    transform: translateY(0);
}

/* ===========================
   Person Groups
   =========================== */
.person-group {
    margin-bottom: 20px;
}

.person-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    user-select: none;
}

.person-header:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.person-header:active {
    transform: translateX(2px);
}

.person-name-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.person-name {
    font-size: 17px;
    font-weight: 700;
    color: white;
}

.gift-count {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.person-right-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.person-budget {
    font-size: 15px;
    font-weight: 700;
    color: white;
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
}

.person-add-gift-btn {
    padding: 6px;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.person-add-gift-btn:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: scale(1.1);
}

.person-add-gift-btn:active {
    transform: scale(0.95);
}

.person-add-gift-btn svg {
    display: block;
}

.collapse-icon {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    cursor: pointer;
}

.person-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.person-gifts {
    padding-left: 12px;
    max-height: 5000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.person-gifts.collapsed {
    max-height: 0;
    opacity: 0;
}

.person-gifts .gift-card {
    margin-left: 8px;
}

.person-total-section {
    padding: 12px 20px;
    margin: 8px 8px 12px 8px;
    background: rgba(76, 175, 80, 0.1);
    border-left: 4px solid #4caf50;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.person-total-section.over-budget {
    background: rgba(244, 67, 54, 0.1);
    border-left-color: #f44336;
}

.person-total-section .total-label {
    color: #4caf50;
    font-size: 14px;
}

.person-total-section.over-budget .total-label {
    color: #f44336;
}

.person-total-section .total-amount {
    color: #4caf50;
    font-size: 16px;
    font-weight: 700;
}

.person-total-section.over-budget .total-amount {
    color: #f44336;
}

.person-header.over-budget {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.person-header.under-budget {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
}

/* ===========================
   Delete Confirmation
   =========================== */
.delete-confirm-message {
    padding: 16px;
    background: #fff5f5;
    border: 2px solid #ffcdd2;
    border-radius: 12px;
    color: #333;
    font-size: 15px;
    line-height: 1.6;
}

.delete-confirm-message p {
    margin-bottom: 12px;
}

.delete-confirm-message p:last-child {
    margin-bottom: 0;
}

.delete-confirm-message strong {
    color: #dc3545;
    font-weight: 700;
}

/* ===========================
   Context Menu
   =========================== */
.context-menu-content {
    max-width: 350px;
}

.context-menu-btn {
    width: 100%;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 600;
}

.context-menu-btn:last-child {
    margin-bottom: 0;
}

.context-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.context-menu-btn:active {
    transform: translateY(0);
}

.context-menu-btn.edit-btn {
    color: #667eea;
    border-color: #667eea;
}

.context-menu-btn.edit-btn:hover {
    background: #f0f2ff;
}

.context-menu-btn.edit-btn svg {
    fill: #667eea;
}

.context-menu-btn.delete-btn {
    color: #dc3545;
    border-color: #dc3545;
}

.context-menu-btn.delete-btn:hover {
    background: #fff5f5;
}

.context-menu-btn.delete-btn svg {
    fill: #dc3545;
}

/* ===========================
   Scrollbar Styling
   =========================== */
.gift-list::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.gift-list::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.gift-list::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 10px;
}

.gift-list::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* ===========================
   Desktop Enhancements (768px and up)
   =========================== */
@media (min-width: 768px) {
    /* Modern subtle gradient background for desktop */
    body {
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
    }

    /* Make container a centered card with shadows */
    .container {
        max-width: 500px;
        height: 90vh;
        max-height: 800px;
        border-radius: 24px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }

    /* Add rounded corners to tabs */
    .tabs {
        border-radius: 24px 24px 0 0;
    }

    .tab-btn:first-child {
        border-radius: 24px 0 0 0;
    }

    .tab-btn:last-child {
        border-radius: 0 24px 0 0;
    }

    /* Add rounded corners to bottom nav */
    .bottom-nav {
        border-radius: 0 0 24px 24px;
    }
}
