/* ========================================
   RESET & BASE STYLES
======================================== */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}

/* ========================================
   HEADER
======================================== */

header {
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

nav {
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--primary-color);
}

/* ========================================
   MAIN CONTENT
======================================== */

main {
    flex: 1;
    padding: 1.5rem 0;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ========================================
   CALCULATOR SECTION
======================================== */

.calculator-section {
    width: 100%;
}

.calculator-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.calculator-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
    color: var(--text-dark);
    text-align: center;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.input-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.125rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Percentage Buttons */
.percentage-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.tip-btn {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.tip-btn:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

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

.custom-tip input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
}

/* People Control */
.people-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--primary-color);
    background: var(--bg-white);
    color: var(--primary-color);
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
}

.people-control input {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--border-color);
    background: var(--bg-light);
    pointer-events: none;
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

/* Calculate Button */
.calculate-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    margin-top: 1.25rem;
}

.calculate-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

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

/* Results */
.results {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 2px solid var(--secondary-color);
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-color);
}

.result-row:last-child {
    border-bottom: none;
}

.result-row span {
    font-size: 1rem;
    color: var(--text-light);
}

.result-row strong {
    font-size: 1.5rem;
    color: var(--text-dark);
}

.split-result {
    margin-top: 0.5rem;
    padding-top: 0.875rem;
    border-top: 2px solid var(--secondary-color);
}

.split-result strong {
    color: var(--secondary-color);
    font-size: 1.75rem;
}

/* Reset Button */
.reset-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-white);
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
}

.reset-btn:hover {
    background: var(--danger-color);
    color: white;
}

/* ========================================
   SIDEBAR
======================================== */

.sidebar {
    height: fit-content;
}

/* ========================================
   AD CONTAINERS
======================================== */

.ad-container {
    margin: 1.25rem auto;
    text-align: center;
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius-md);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-top {
    margin-top: 0;
    margin-bottom: 1.25rem;
}

.ad-content {
    margin: 1.5rem 0;
}

.ad-sidebar {
    margin: 0 auto;
}

.ad-mobile-anchor {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    margin: 0;
    padding: 0.5rem 0;
}

/* ========================================
   HOW TO USE SECTION
======================================== */

.how-to-section {
    background: var(--bg-white);
    padding: 2rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.how-to-section h2 {
    font-size: 1.875rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.step {
    text-align: center;
    padding: 1.25rem;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    transition: transform 0.3s, box-shadow 0.3s;
}

.step:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.step-number {
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 1rem;
}

.step h3 {
    font-size: 1.25rem;
    margin-bottom: 0.625rem;
    color: var(--text-dark);
}

.step p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ========================================
   TIPPING GUIDE SECTION
======================================== */

.guide-section {
    background: var(--bg-white);
    padding: 2rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.guide-section h2 {
    font-size: 1.875rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.guide-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.guide-item {
    padding: 1.25rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.guide-item h3 {
    font-size: 1.25rem;
    margin-bottom: 0.875rem;
    color: var(--primary-color);
}

.guide-item ul {
    list-style: none;
}

.guide-item li {
    padding: 0.5rem 0;
    color: var(--text-dark);
    line-height: 1.6;
}

.guide-item li strong {
    color: var(--primary-color);
}

/* ========================================
   FOOTER
======================================== */

footer {
    background: var(--text-dark);
    color: white;
    padding: 2rem 0 1rem;
    margin-top: 2rem;
    margin-bottom: 0;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.footer-section h4 {
    margin-bottom: 0.875rem;
    color: white;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

@media (max-width: 968px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .ad-mobile-anchor {
        display: block;
    }
    
    footer {
        margin-bottom: 0;
        padding-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    header .container {
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    nav {
        width: auto;
        justify-content: center;
    }
    
    main {
        padding: 1.25rem 0;
    }
    
    .calculator-card {
        padding: 1.25rem;
    }
    
    .percentage-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .steps {
        grid-template-columns: 1fr;
    }
    
    .guide-content {
        grid-template-columns: 1fr;
    }
    
    .how-to-section,
    .guide-section {
        padding: 1.5rem 1rem;
    }
    
    .ad-container {
        position: relative;
        z-index: 1;
    }
    
    header {
        position: relative;
    }
    
    footer {
        margin-bottom: 0;
        padding-bottom: 1rem;
    }
    
    body {
        padding-bottom: 0;
        margin-bottom: 0;
    }
    
    .ad-container.ad-bottom {
        margin-bottom: 0;
    }
    
    .ad-mobile-anchor {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.25rem;
    }
    
    nav {
        gap: 0.875rem;
        font-size: 0.9rem;
    }
    
    .calculator-card {
        padding: 1rem;
    }
    
    .calculator-card h2 {
        font-size: 1.5rem;
    }
    
    .percentage-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-row strong {
        font-size: 1.25rem;
    }
    
    .split-result strong {
        font-size: 1.5rem;
    }
}

/* ========================================
   ANIMATIONS
======================================== */

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

.results {
    animation: fadeIn 0.3s ease-out;
}

/* ========================================
   PRINT STYLES
======================================== */

@media print {
    header, footer, .ad-container, nav, .reset-btn {
        display: none;
    }
    
    .calculator-card {
        box-shadow: none;
    }
}