:root {
    --primary: #FF5A5F;
    /* Red/Orange for general actions */
    --primary-light: #FF8A8D;
    --secondary: #00A699;
    /* Teal green for stock/safe actions */
    --bg-color: #F7F7F9;
    --card-bg: #FFFFFF;
    --text-main: #222222;
    --text-muted: #717171;
    --border: #EBEBEB;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --border-radius: 16px;
    --font-family: 'Outfit', sans-serif;
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1 {
    font-weight: 600;
    font-size: 1.5rem;
}

h2 {
    font-weight: 600;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

h3 {
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

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

.bg-blue {
    background-color: #E8F4FD;
    color: #1E88E5;
}

.bg-orange {
    background-color: #FFF3E0;
    color: #F57C00;
}

/* Layout & Header */
.app-header {
    background: var(--card-bg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.app-header h1 {
    flex: 1;
    text-align: center;
    margin-right: 2rem;
    /* Balance back button */
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#back-btn,
#edit-btn,
#cart-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

#cart-btn {
    color: var(--primary);
}

#edit-btn {
    color: var(--primary);
}

#back-btn:hover,
#edit-btn:hover,
#cart-btn:hover {
    background: var(--border);
}

.badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

#back-btn:hover {
    background: var(--border);
}

main {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 64px);
}

/* Views & Animations */
.view {
    display: none;
}

.view.active {
    display: block;
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.pop {
    animation: pop 0.2s ease;
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.dashboard-header p {
    font-size: 1.1rem;
    font-weight: 300;
}

.recipes-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.recipe-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.recipe-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--border);
}

.card-content {
    flex: 1;
}

.card-content .description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-arrow {
    color: #D1D1D1;
    font-size: 1.2rem;
    margin-left: 1rem;
    transition: var(--transition);
}

.recipe-card:hover .card-arrow {
    color: var(--primary);
    transform: translateX(4px);
}

/* Badges */
.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.stock-ok {
    background: #E8F5E9;
    color: #2E7D32;
}

.stock-empty {
    background: #FFEBEE;
    color: #C62828;
}

/* Recipe Detail */
.recipe-header-info {
    margin-bottom: 1.5rem;
}

.recipe-desc {
    font-size: 1.05rem;
    color: var(--text-muted);
}

.controls-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.control-panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.counter {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-color);
    padding: 0.25rem;
    border-radius: 20px;
}

.btn-count {
    background: var(--card-bg);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    color: var(--text-main);
    transition: var(--transition);
}

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

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

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

.count-value {
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

/* Sections */
.bg-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.bg-card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bg-card h2 i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Ingredients */
.ingredients-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ingredients-list li {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.ingredients-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ing-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ing-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.ing-qty-badge {
    background: var(--bg-color);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    white-space: nowrap;
}

.ing-unit {
    margin-left: 0.25rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Steps */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.step-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.step-text {
    flex: 1;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Reheating section */
.reheating-section {
    margin-top: 1rem;
}

.reheating-section h2 i {
    color: #FF9800;
}

.reheating-info {
    font-style: italic;
    color: #555;
    background: #fffcf2;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #FF9800;
}

/* Actions (Edit Button) */
#edit-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--primary);
    cursor: pointer;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#edit-btn:hover {
    background: var(--bg-color);
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-color);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.form-section {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.form-section h3 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.edit-item-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.edit-item-row input,
.edit-item-row textarea {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.edit-item-row input.small {
    flex: 0 0 80px;
}

.edit-item-row input.med {
    flex: 0 0 120px;
}

.btn-remove {
    background: #FFEBEE;
    color: #C62828;
    border: none;
    border-radius: 6px;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-secondary {
    background: var(--bg-color);
    border: 1px dashed var(--border);
    color: var(--text-main);
    font-weight: 500;
    padding: 0.75rem;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    display: block;
    text-align: center;
    font-family: inherit;
    font-size: 0.95rem;
}

.btn-secondary:hover {
    background: #eee;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #fafafa;
}

.btn-cancel,
.btn-save {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
}

.btn-cancel {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-save {
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* Cart Styling */
.floating-action-container {
    padding: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(255, 90, 95, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 90, 95, 0.5);
}

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

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

.btn-clear-cart {
    background: #FFEBEE;
    color: #C62828;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-clear-cart:hover {
    background: #FFCDD2;
}

.cart-recipe-group {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.cart-recipe-group h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-recipe-group h3 .remove-recipe-cart {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.cart-recipe-group h3 .remove-recipe-cart:hover {
    color: var(--primary);
}

.cart-ingredient {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
}

.cart-ingredient:last-child {
    border-bottom: none;
}

.cart-ing-name {
    font-weight: 500;
}

.cart-ing-qty {
    font-weight: 600;
    color: var(--primary);
}

.selectable-ing {
    cursor: pointer;
    transition: all 0.2s ease;
}

.selectable-ing:hover {
    background: #fdfdfd;
}

.check-icon {
    color: var(--border);
    margin-right: 8px;
    font-size: 1.1rem;
    vertical-align: middle;
}

.ing-crossed {
    opacity: 0.5;
}

.ing-crossed .cart-ing-name {
    text-decoration: line-through;
}

.ing-crossed .cart-ing-qty {
    color: var(--text-muted);
}

.ing-crossed .check-icon {
    color: #4caf50;
}