/* Bill Splitter Pro - Optimized Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #000;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
}

.label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

/* Form Elements */
.input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
    max-width: 100%;
}

.input:focus {
    outline: none;
    border-color: #000;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: 2px solid #000;
    background: white;
    color: #000;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: #000;
    color: white;
}

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

.btn-primary {
    background: #000;
    color: white;
}

.btn-primary:hover {
    background: #333;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    min-width: auto;
}

.btn-danger {
    border-color: #dc2625;
    color: #dc2625;
}

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

.actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Table */
.table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

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

.table th {
    background: #000;
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table th:nth-child(n+2):nth-last-child(n+3),
.table th:last-child,
.table th:nth-last-child(2) {
    text-align: center;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
    background: #fafafa;
}

.table input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.table input:focus {
    outline: none;
    border-color: #666;
}

.add-item-col {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
}

.amount-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.total-cell {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #000;
}

.totals-row {
    background: #f8f9fa;
    border-top: 2px solid #000;
}

.totals-row td {
    font-weight: 600;
    padding: 1.5rem 1rem;
}

.breakdown {
    text-align: right;
    font-size: 0.9rem;
    line-height: 1.6;
}

.breakdown-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.grand-total {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: right;
}

/* Modal */
.save-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    margin: 1rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-text {
    color: #666;
    margin-bottom: 1.5rem;
}

.link-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.link-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    font-size: 0.9rem;
}

/* Status Messages */
.status {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.status-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #99d3ff;
}

/* Utilities */
.text-center {
    text-align: center;
}

.no-print {
    /* Will be hidden in print styles */
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .title {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .header {
        padding: 0;
        margin-bottom: 1rem;
    }
    
    .controls {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        padding: 0;
        margin-bottom: 1rem;
    }
    
    .input {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Make table horizontally scrollable on mobile only when needed */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        width: 100%; /* Let table use available width */
        table-layout: auto; /* Allow columns to size naturally */
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
        min-width: 80px; /* Minimum column width */
    }
    
    .table th:first-child,
    .table td:first-child {
        min-width: 100px; /* Person name column slightly wider */
    }
    
    .table th:nth-last-child(2),
    .table td:nth-last-child(2) {
        min-width: 80px; /* Total column */
    }
    
    .table th:last-child,
    .table td:last-child {
        min-width: 90px; /* Actions column */
    }
    
    .table input {
        width: 100%;
        min-width: 50px;
        padding: 0.4rem;
        font-size: 0.85rem;
    }
    
    /* Add item column stays small */
    .add-item-col {
        width: 40px;
        min-width: 40px;
        max-width: 40px;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .container {
        margin: 0;
        padding: 0;
    }
    
    .header,
    .table-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
