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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 20px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

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

.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab {
    flex: 1;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    transform: translateY(-2px);
}

.tab.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.tab-content {
    padding: 20px;
    min-height: 500px;
}

.section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.section.active {
    display: block;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 15px;
    align-items: end;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

input[type="text"], input[type="number"], input[type="password"], select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 100px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

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

.btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.ingredient-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    flex-wrap: wrap;
    gap: 15px;
}

.ingredient-item:hover {
    border-color: #007bff;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-3px);
}

.ingredient-item > div:first-child {
    flex: 1;
    min-width: 200px;
}

.ingredient-item > div:last-child {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.meal-ingredient {
    background: linear-gradient(135deg, #e8f4fd 0%, #ffffff 100%);
    border: 2px solid #b8daff;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    flex-wrap: wrap;
    gap: 15px;
}

.meal-ingredient:hover {
    border-color: #007bff;
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.15);
    transform: translateY(-3px);
}

.meal-ingredient > div:first-child {
    flex: 1;
    min-width: 200px;
}

.totals {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #c3e6cb;
    border-radius: 15px;
    padding: 25px;
    margin-top: 20px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.15);
}

.totals h3 {
    color: #155724;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.autocomplete-container {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background 0.2s ease;
    font-size: 0.9rem;
}

.autocomplete-item:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    padding-right: 50px;
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 1.2rem;
    pointer-events: none;
}

.meal-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.meal-card:hover {
    border-color: #007bff;
    box-shadow: 0 12px 35px rgba(0,0,0,0.1);
    transform: translateY(-5px);
}

.meal-card h3 {
    color: #007bff;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.meal-card .meal-ingredients-list {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.meal-card .meal-ingredients-list ul {
    margin-top: 8px;
    list-style-type: none;
    padding-left: 0;
}

.meal-card .meal-ingredients-list li {
    margin: 5px 0;
    padding: 8px;
    background: white;
    border-radius: 5px;
    font-size: 0.85rem;
    border-left: 4px solid #007bff;
    word-wrap: break-word;
}

.meal-card > div:last-child {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.message {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 600;
}

.message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #c3e6cb;
}

.message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 15px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #007bff;
    font-size: 1.3rem;
}

/* Button groups for mobile */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: 20px;
}

.button-group .btn {
    flex: 1;
    min-width: 120px;
}

/* Conversion Section Styles */
.conversion-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e9ecef;
}

.conversion-section h2 {
    color: #007bff;
    margin-bottom: 30px;
    text-align: center;
    font-size: 1.8rem;
}

.conversion-group {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.conversion-group h3 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.3rem;
    text-align: center;
}

.conversion-input {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: end;
}

.conversion-input .form-group {
    margin-bottom: 0;
}

.conversion-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.conversion-result {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.conversion-result:hover {
    border-color: #007bff;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
    transform: translateY(-2px);
}

.conversion-result.input-unit {
    border-color: #fd7e14;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    box-shadow: 0 4px 15px rgba(253, 126, 20, 0.3);
}

.unit-label {
    display: block;
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 5px;
}

.unit-value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    color: #007bff;
}

.conversion-result.input-unit .unit-value {
    color: #fd7e14;
}

.dry-conversion {
    border-color: #28a745;
}

.dry-conversion h3 {
    color: #28a745;
}

.liquid-conversion {
    border-color: #007bff;
}

.liquid-conversion h3 {
    color: #007bff;
}

.conversion-reference {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 2px solid #b8daff;
    border-radius: 15px;
    padding: 25px;
    margin-top: 30px;
}

.conversion-reference h3 {
    color: #007bff;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.reference-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.reference-column h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1rem;
    text-align: center;
}

.reference-column ul {
    list-style: none;
    padding: 0;
}

.reference-column li {
    background: white;
    padding: 8px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    font-weight: 500;
    transition: all 0.2s ease;
}

.reference-column li:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        margin: 0;
        border-radius: 10px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.6rem;
    }
    
    .header p {
        font-size: 0.8rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab {
        padding: 12px;
        font-size: 0.85rem;
        min-height: 50px;
    }
    
    .tab-content {
        padding: 15px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row .form-group {
        min-width: unset;
        margin-bottom: 15px;
    }
    
    .ingredient-item, .meal-ingredient {
        flex-direction: column;
        text-align: center;
        align-items: stretch;
        gap: 15px;
        padding: 15px;
    }
    
    .ingredient-item > div:first-child,
    .meal-ingredient > div:first-child {
        min-width: unset;
        text-align: center;
    }
    
    .ingredient-item > div:last-child,
    .meal-ingredient > div:last-child {
        justify-content: center;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 10px 16px;
        min-width: 90px;
    }
    
    .meal-card {
        padding: 15px;
    }
    
    .meal-card h3 {
        font-size: 1.1rem;
    }
    
    .meal-card .meal-ingredients-list li {
        font-size: 0.8rem;
        padding: 6px;
    }
    
    .meal-card > div:last-child {
        justify-content: center;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .modal-content h3 {
        font-size: 1.1rem;
    }
    
    .button-group .btn {
        min-width: 100px;
        flex: 1 1 45%;
    }
    
    .totals {
        padding: 20px;
    }
    
    .totals h3 {
        font-size: 1.1rem;
    }
    
    .autocomplete-item {
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    
    /* Fix for iPhone input zoom */
    input[type="text"], input[type="number"], input[type="password"], select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Improve touch targets */
    .btn, .autocomplete-item {
        min-height: 44px; /* iOS recommended touch target size */
    }
    
    /* Mobile Responsive for Conversions */
    .conversion-input {
        flex-direction: column;
        gap: 15px;
    }
    
    .conversion-results {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .reference-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .conversion-section h2 {
        font-size: 1.5rem;
    }
    
    .conversion-group h3 {
        font-size: 1.2rem;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.4rem;
    }
    
    .tab {
        font-size: 0.8rem;
        padding: 10px 5px;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 8px 12px;
        min-width: 80px;
    }
    
    .meal-card .meal-ingredients-list li {
        font-size: 0.75rem;
    }
    
    .button-group .btn {
        min-width: 80px;
        font-size: 0.8rem;
    }
    
    /* Stack buttons vertically on very small screens when needed */
    .ingredient-item > div:last-child,
    .meal-ingredient > div:last-child,
    .meal-card > div:last-child {
        flex-direction: column;
        gap: 8px;
    }
    
    .conversion-results {
        grid-template-columns: 1fr;
    }
    
    .conversion-group {
        padding: 20px 15px;
    }
    
    .unit-value {
        font-size: 1.2rem;
    }
}

/* Landscape orientation adjustments for phones */
@media (max-width: 768px) and (orientation: landscape) {
    .tabs {
        flex-direction: row;
    }
    
    .tab {
        font-size: 0.8rem;
        padding: 8px;
        min-height: 45px;
    }
    
    .header {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.3rem;
        margin-bottom: 5px;
    }
    
    .tab-content {
        padding: 10px;
    }
}

/* Focus styles for better accessibility */
.btn:focus, input:focus, select:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Improve scrollbar on mobile */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}
    
.login-container {
    max-width: 480px;
}

.sign-out {
    margin-top: 1rem;
}
