/* style.css - TipWise Premium Tip Calculator */

:root {
    --primary-mint: #a8e063;
    --primary-teal: #56ab2f;
    --gradient: linear-gradient(135deg, var(--primary-mint) 0%, var(--primary-teal) 100%);
    
    --bg-light: #f4f7f6;
    --card-light: #ffffff;
    --text-primary-light: #2d3436;
    --text-secondary-light: #636e72;
    --border-light: #dfe6e9;
    --input-bg-light: #f1f2f6;
    
    --bg-dark: #0f172a;
    --card-dark: #1e293b;
    --text-primary-dark: #f8fafc;
    --text-secondary-dark: #94a3b8;
    --border-dark: #334155;
    --input-bg-dark: #0f172a;

    --accent: #56ab2f;
    --accent-hover: #458a25;
    --error: #ff7675;
    
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-lg: 24px;
    --radius-md: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    transition: var(--transition);
    overflow-x: hidden;
    min-height: 100vh;
}

body.light-mode {
    background-color: var(--bg-light);
    color: var(--text-primary-light);
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-primary-dark);
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

/* Header */
.header {
    background: var(--gradient);
    padding: 3rem 1.5rem 5rem;
    color: white;
    text-align: center;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.logo {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.header p {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    padding: 0 1.5rem;
    margin-top: -3rem;
}

/* Cards */
.calculator-card, .result-card, .history-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.dark-mode .calculator-card, 
.dark-mode .result-card, 
.dark-mode .history-section {
    background: var(--card-dark);
    border: 1px solid var(--border-dark);
}

/* Input Groups */
.input-group {
    margin-bottom: 1.5rem;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary-light);
}

.dark-mode label {
    color: var(--text-secondary-dark);
}

/* Bill Input */
.bill-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.bill-input-wrapper .currency-symbol {
    position: absolute;
    left: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-teal);
}

.result-value .currency-symbol {
    font-size: 1.5rem;
    margin-right: 0.2rem;
    vertical-align: super;
    opacity: 0.9;
}

input[type="number"], select {
    width: 100%;
    padding: 1rem;
    padding-left: 2.5rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--input-bg-light);
    font-size: 1.25rem;
    font-weight: 600;
    color: inherit;
    transition: var(--transition);
}

.dark-mode input[type="number"], 
.dark-mode select {
    background: var(--input-bg-dark);
    border: 1px solid var(--border-dark);
}

input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(86, 171, 47, 0.2);
}

/* Currency Select */
.currency-select {
    padding: 0.4rem 0.8rem;
    padding-left: 0.8rem;
    font-size: 0.85rem;
    width: auto;
    border-radius: 8px;
}

/* Tip Grid */
.tip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.tip-btn {
    padding: 0.75rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--input-bg-light);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary-light);
    cursor: pointer;
    transition: var(--transition);
}

.dark-mode .tip-btn {
    background: var(--input-bg-dark);
    color: var(--text-primary-dark);
    border: 1px solid var(--border-dark);
}

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

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

#custom-tip {
    padding: 0.75rem;
    font-size: 1rem;
    text-align: center;
    padding-left: 0.75rem;
}

/* Slider */
.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--input-bg-light);
    outline: none;
}

.dark-mode .slider {
    background: var(--border-dark);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-teal);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* Badge */
.badge {
    background: var(--primary-teal);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-teal);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Uneven Split */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.info-tag {
    font-size: 0.7rem;
    background: rgba(86, 171, 47, 0.1);
    color: var(--primary-teal);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.person-inputs-list {
    margin-top: 1rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.person-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--input-bg-light);
    border-radius: var(--radius-md);
    animation: slideIn 0.3s ease-out;
}

.dark-mode .person-row {
    background: var(--input-bg-dark);
    border: 1px solid var(--border-dark);
}

.person-info {
    display: flex;
    flex-direction: column;
}

.person-row span {
    font-weight: 600;
    font-size: 0.9rem;
}

.person-total-hint {
    font-size: 0.75rem;
    color: var(--primary-teal);
    font-weight: 500;
}

.person-row input {
    width: 120px;
    padding: 0.5rem;
    font-size: 1rem;
    text-align: right;
    padding-left: 0.5rem;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.warning {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.hidden {
    display: none;
}

/* Rounding Actions */
.round-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-teal);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.5rem;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--primary-teal);
    border-radius: 10px;
    background: transparent;
    color: var(--primary-teal);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: rgba(86, 171, 47, 0.1);
}

.secondary-btn:active, .icon-btn:active {
    transform: scale(0.92);
}

.text-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-secondary-light);
    font-size: 0.9rem;
    padding: 0.5rem;
    cursor: pointer;
}

.dark-mode .text-btn {
    color: var(--text-secondary-dark);
}

/* Result Card */
.result-card {
    background: var(--primary-teal);
    color: white;
}

.dark-mode .result-card {
    background: var(--primary-teal);
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-label {
    display: flex;
    flex-direction: column;
}

.result-label span {
    font-weight: 700;
}

.result-label small {
    opacity: 0.8;
}

.result-value {
    font-size: 2rem;
    font-weight: 800;
}

.result-row.total .result-value {
    font-size: 2.5rem;
}

.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 1.5rem 0;
}

.summary-details {
    margin-bottom: 1.5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    opacity: 0.9;
    font-size: 0.9rem;
}

.summary-item.grand-total {
    font-weight: 700;
    font-size: 1rem;
    opacity: 1;
}

#save-bill {
    background: white;
    color: var(--primary-teal);
}

#reset-btn {
    color: white;
    opacity: 0.8;
}

/* History */
.history-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    padding: 1rem;
    background: var(--input-bg-light);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark-mode .history-item {
    background: var(--input-bg-dark);
}

.history-info {
    display: flex;
    flex-direction: column;
}

.history-info .date {
    font-size: 0.75rem;
    color: var(--text-secondary-light);
}

.dark-mode .history-info .date {
    color: var(--text-secondary-dark);
}

.history-total {
    font-weight: 700;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary-light);
    font-style: italic;
    padding: 1rem;
}

/* Theme Toggle Icons */
#theme-toggle .moon-icon { display: none; }
.dark-mode #theme-toggle .sun-icon { display: none; }
.dark-mode #theme-toggle .moon-icon { display: block; }

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 12px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

/* Utilities */
.hidden { display: none; }

@media (max-width: 400px) {
    .tip-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
