/* --- Variables & Theme Setup --- */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #ec4899;
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --nav-bg: #ffffff;
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --font-family: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-hover: #818cf8;
    --bg-color: #111827;
    --card-bg: rgba(31, 41, 55, 0.7);
    --text-main: #f9fafb;
    --text-sub: #9ca3af;
    --border-color: #374151;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --nav-bg: #1f2937;
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

input, select, textarea, button {
    -webkit-user-select: text;
    user-select: text;
}

/* --- Navigation --- */
.navbar {
    background-color: var(--nav-bg);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Updated Logo Image Styling */
.app-logo {
    height: 40px;
    width: auto;
    display: block;
}

/* Hamburger Menu Button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-main);
    font-size: 1.5rem;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    min-width: 44px;
    align-items: center;
    justify-content: center;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-main);
    margin: 5px 0;
    transition: all 0.3s ease;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
    background-color: var(--primary-color);
    color: #fff;
}

@media (max-width: 599px) {
    .navbar {
        flex-wrap: nowrap;
        gap: 0;
    }
    
    .hamburger-btn {
        display: flex;
        order: 3;
    }
    
    .nav-links {
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--nav-bg);
        flex-direction: column;
        gap: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-links.active {
        max-height: 300px;
    }
    
    .nav-links a {
        display: block;
        padding: 0.75rem 1rem;
        border-radius: 0;
        width: 100%;
        text-align: left;
        font-size: 0.95rem;
    }
}

@media (min-width: 600px) {
    .navbar {
        padding: 1rem 2rem;
        flex-wrap: nowrap;
        gap: 0;
    }
    
    .hamburger-btn {
        display: none;
    }
    
    .nav-links {
        width: auto;
        position: static;
        gap: 1.5rem;
        justify-content: flex-end;
        max-height: none;
    }
    
    .nav-links a {
        font-size: 0.95rem;
        padding: 0.5rem 1rem;
    }
}

/* --- Layout --- */
.container {
    max-width: 800px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    flex: 1;
    width: 100%;
}

.hero-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.hero-section h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    word-break: break-word;
}

.hero-section p {
    font-size: 0.95rem;
    color: var(--text-sub);
}

@media (min-width: 600px) {
    .container {
        margin: 2rem auto;
        padding: 0 1rem;
    }
    
    .hero-section {
        margin-bottom: 2rem;
    }
    
    .hero-section h1 {
        font-size: 2.5rem;
    }
}

/* --- Components --- */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.5rem;
    border: var(--glass-border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.converter-grid, .splitter-grid, .ai-input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .card {
        padding: 2rem;
        border-radius: 20px;
    }
    
    .converter-grid { 
        grid-template-columns: 1fr auto 1fr; 
        align-items: end;
        gap: 1.5rem;
    }
    .splitter-grid { 
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    .ai-input-grid { 
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    .input-group.full-width { 
        grid-column: span 2; 
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
}

input, select {
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 1rem;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
}

input:focus, select:focus {
    outline: 2px solid var(--primary-color);
    border-color: transparent;
}

@media (min-width: 600px) {
    input, select {
        padding: 0.8rem;
        min-height: 40px;
    }
}

/* --- Buttons --- */
.primary-btn {
    width: 100%;
    padding: 0.9rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.primary-btn:active {
    transform: translateY(0);
}

.swap-container {
    display: flex;
    justify-content: center;
    padding-bottom: 0.2rem;
    align-items: center;
}

#swap-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    transition: transform 0.3s;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

#swap-btn:hover {
    transform: rotate(180deg);
}

#swap-btn:active {
    opacity: 0.8;
}

@media (min-width: 600px) {
    .primary-btn {
        min-height: 40px;
        padding: 1rem;
    }
    
    #swap-btn {
        width: 40px;
        height: 40px;
        min-height: 40px;
    }
}

/* --- Results Area --- */
.result-display {
    text-align: center;
    margin: 1.5rem 0;
    padding: 1.2rem;
    background-color: rgba(79, 70, 229, 0.1);
    border-radius: 15px;
}

[data-theme="dark"] .result-display {
    background-color: rgba(255,255,255, 0.05);
}

#result-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    word-break: break-word;
}

.sub-text {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 0.5rem;
}

@media (min-width: 600px) {
    .result-display {
        margin: 2rem 0;
        padding: 1.5rem;
    }
    
    #result-value {
        font-size: 2rem;
    }
    
    .sub-text {
        font-size: 0.9rem;
    }
}

/* --- Bill Splitter Specifics --- */
.people-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.people-control button {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.people-control button:active {
    opacity: 0.8;
}

.quick-tips {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.chip {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-main);
    cursor: pointer;
    min-height: 32px;
    -webkit-tap-highlight-color: transparent;
}

.chip:hover {
    background: var(--border-color);
}

.chip:active {
    opacity: 0.8;
}

@media (min-width: 600px) {
    .people-control button {
        width: 40px;
        height: 40px;
        min-height: 40px;
    }
    
    .chip {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
        min-height: 28px;
    }
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.money.highlight {
    font-weight: 800;
    color: var(--secondary-color);
    font-size: 1.5rem;
}

/* --- AI Result Box --- */
.ai-result-box {
    margin-top: 2rem;
    padding: 1.5rem;
    border-left: 4px solid var(--secondary-color);
    background: rgba(236, 72, 153, 0.05);
    border-radius: 0 10px 10px 0;
}

.hidden {
    display: none;
}

/* --- Ad Placeholders --- */
.ad-container {
    background-color: rgba(0,0,0,0.03);
    border: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    font-size: 0.75rem;
    margin: 0.5rem auto;
    padding: 0.5rem;
}

.ad-banner {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 50px;
}

.ad-rectangle {
    width: 100%;
    max-width: 300px;
    height: 250px;
    margin: 0 auto;
}

@media (min-width: 600px) {
    .ad-container {
        margin: 1rem auto;
    }
    
    .ad-banner {
        max-width: 728px;
        min-height: 90px;
    }
}

/* --- Floating Actions --- */
.floating-actions {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    z-index: 200;
}

.float-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.2s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
    min-width: 48px;
}

.float-btn:hover {
    transform: scale(1.1);
}

.float-btn:active {
    transform: scale(0.95);
}

@media (min-width: 600px) {
    .floating-actions {
        bottom: 2rem;
        right: 2rem;
        gap: 1rem;
    }
    
    .float-btn {
        width: 50px;
        height: 50px;
        min-height: 50px;
        min-width: 50px;
    }
}

/* Theme Icon Logic */
.icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Mobile Responsive */
@media (max-width: 599px) {
    body {
        font-size: 14px;
    }
    
    .navbar { 
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .nav-links { 
        gap: 0.3rem;
        font-size: 0.85rem;
    }
    
    .hero-section h1 { 
        font-size: 1.5rem;
        line-height: 1.2;
    }
    
    .hero-section p {
        font-size: 0.85rem;
    }
    
    .divider {
        margin: 1.5rem 0;
    }
    
    .result-row {
        font-size: 1rem;
    }
    
    .money.highlight {
        font-size: 1.3rem;
    }
    
    .ai-result-box {
        margin-top: 1.5rem;
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-sub);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

footer p {
    margin: 0.3rem 0;
}

.disclaimer {
    font-size: 0.75rem;
}

.disclaimer-text {
    font-size: 0.75rem;
    color: var(--text-sub);
}

/* --- Settings Page --- */
.settings-info {
    background-color: rgba(79, 70, 229, 0.08);
    border-left: 4px solid var(--primary-color);
    padding: 1.2rem;
    border-radius: 0 8px 8px 0;
    margin-top: 1.5rem;
}

.settings-info p {
    margin: 0.6rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
}

.settings-info strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* --- Additional Mobile Optimizations --- */
@media (max-width: 599px) {
    /* Prevent double tap zoom on buttons */
    button, a, input, select {
        touch-action: manipulation;
    }
    
    /* Prevent zoom on inputs */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px;
    }
    
    /* Add bottom padding to account for mobile keyboards */
    main {
        padding-bottom: 2rem;
    }
    
    /* Make links more tappable */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}