/* Recipe Manager - Modern Design */

/* CSS Variables for theming */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Reset & Base */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6; 
    padding: 20px; 
    max-width: 1400px; 
    margin: 0 auto; 
    background: var(--background);
    color: var(--text-primary);
}

/* Header */
header { 
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
    color: #fff; 
    padding: 1.5rem 2rem; 
    margin-bottom: 2rem; 
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 { 
    margin-bottom: 0.75rem;
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

nav a { 
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none; 
    font-weight: 500;
    transition: all 0.2s;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}

nav a:hover { 
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

/* Container */
.container { 
    background: var(--surface);
    padding: 2rem; 
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* Buttons */
.btn { 
    display: inline-block; 
    padding: 0 20px; 
    background: var(--primary-color);
    color: #fff; 
    text-decoration: none; 
    border-radius: var(--radius-md);
    border: none; 
    cursor: pointer;
    height: 40px;
    line-height: 40px;
    box-sizing: border-box;
    vertical-align: middle;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn:hover { 
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

.btn-secondary { 
    background: var(--secondary-color);
}

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

.btn-remove { 
    background: var(--danger-color);
    color: #fff; 
}

.btn-remove:hover { 
    background: var(--danger-hover);
}

.btn-edit {
    background: #f59e0b;
    color: #fff;
}

.btn-edit:hover {
    background: #d97706;
}

.btn-small { 
    padding: 0 12px; 
    font-size: 13px;
    height: 40px; 
    line-height: 40px;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Alerts */
.alert { 
    padding: 1rem 1.25rem;
    margin-bottom: 1rem; 
    border-radius: var(--radius-md);
    font-weight: 500;
    border-left: 4px solid;
}

.alert-success { 
    background: #d1fae5;
    color: #065f46; 
    border-color: var(--success-color);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: var(--danger-color);
}

/* Tables */
table { 
    width: 100%; 
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th, td { 
    padding: 16px;
    text-align: left; 
    vertical-align: middle;
}

th { 
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff; 
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    cursor: pointer; 
    user-select: none;
    border-bottom: 2px solid var(--primary-color);
}

th:hover { 
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
}

td {
    border-bottom: 1px solid var(--border);
}

/* Default row background */
tr td {
    background: var(--surface);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td { 
    background: #f8fafc;
}

th.sortable::after { 
    content: ' ⇅'; 
    opacity: 0.4;
    margin-left: 4px;
}

th.sortable {
    user-select: none;
    transition: background 0.2s;
}

.sort-arrow {
    font-size: 0.875em;
    margin-left: 6px;
    opacity: 1;
}

/* Action column styling - FIXED ALIGNMENT */
th.actions-column,
td.actions-column {
    text-align: right;
    padding-right: 16px !important;
}

th.actions-column {
    padding-right: 16px !important;
}

/* Forms */
form { 
    margin: 1rem 0; 
}

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

label { 
    display: block; 
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

input[type="text"], 
input[type="number"], 
input[type="date"], 
select,
textarea { 
    width: 100%; 
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: all 0.2s;
    background: var(--surface);
}

input[type="text"]:focus, 
input[type="number"]:focus, 
input[type="date"]:focus, 
select:focus,
textarea:focus { 
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[type="file"] { 
    width: 100%; 
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

textarea { 
    min-height: 120px;
    resize: vertical; 
    font-family: inherit;
}

input[type="checkbox"] { 
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Badges */
.badge { 
    display: inline-block; 
    padding: 4px 10px;
    background: var(--primary-color);
    color: #fff; 
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    margin: 2px;
    letter-spacing: 0.025em;
}

/* Search */
.search-box { 
    margin-bottom: 2rem; 
}

.search-box input { 
    display: inline-block; 
    width: 70%; 
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
}

/* Pagination */
.pagination { 
    margin-top: 2rem; 
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span { 
    display: inline-block;
    padding: 10px 16px;
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none; 
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-weight: 500;
    transition: all 0.2s;
    line-height: 24px;
    box-sizing: border-box;
}

.pagination a:hover { 
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pagination a.active { 
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination span.disabled { 
    background: var(--border);
    color: var(--text-secondary);
    pointer-events: none; 
    opacity: 0.5;
}

.pagination a:hover { 
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pagination a.active { 
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination span.disabled { 
    background: var(--border);
    color: var(--text-secondary);
    pointer-events: none; 
    opacity: 0.5;
}

/* Recipe-specific */
.recipe-card { 
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1rem; 
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.instruction-step { 
    background: #f8fafc;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    transition: all 0.2s;
}

.instruction-step:hover {
    background: #f1f5f9;
    box-shadow: var(--shadow-sm);
}

.step-number { 
    font-weight: 700;
    font-size: 1.25em; 
    color: var(--primary-color);
    margin-right: 12px;
}

/* Ingredient rows */
.ingredient-row { 
    display: grid; 
    grid-template-columns: 1fr 1fr 100px 150px 40px; 
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.ingredient-row .btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
}

/* Conditional fields */
.conditional { 
    display: none; 
    margin-left: 20px; 
    padding: 1rem;
    background: #f8fafc;
    border-left: 3px solid var(--primary-color);
    margin-top: 12px;
    border-radius: var(--radius-md);
}

/* Links */
a.recipe-link { 
    color: var(--primary-color);
    text-decoration: none; 
    font-weight: 600;
    transition: color 0.2s;
}

a.recipe-link:hover { 
    color: var(--primary-hover);
    text-decoration: underline; 
}

/* Headings */
h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

h3 { 
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Media embeds */
.media-section {
    background: #f8fafc;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.media-section img,
.media-section video,
.media-section iframe {
    max-width: 100%;
    max-height: 500px;
    display: block;
    margin: 12px 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Rating badge */
.rating-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    margin-left: 20px;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.rating-high {
    background: var(--success-color);
}

.rating-medium {
    background: var(--warning-color);
    color: var(--text-primary);
}

.rating-low {
    background: var(--danger-color);
}

.rating-none {
    background: var(--secondary-color);
    color: #fff;
}

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

.recipe-title-section {
    display: flex;
    align-items: center;
    flex: 1;
}

/* Bottom button container */
.bottom-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Form button container */
.form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 2rem;
    align-items: center;
}

.form-buttons .btn-cancel {
    margin-left: auto;
}

/* Cuisine and Meal tags section */
.tags-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.tags-row-three {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.tags-section {
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: #f8fafc;
}

.tags-section h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.tags-section label {
    font-weight: 500;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.875rem;
}

.tags-section input[type="checkbox"] {
    margin-right: 10px;
}

.cuisine-badge,
.tag-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--primary-color);
    color: #fff;
    border-radius: var(--radius-sm);
    margin: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Fix ingredient unit dropdown and textbox styling */
.ingredient-row select {
    height: 38px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.ingredient-row select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    outline: none;
}

.ingredient-row input[type="text"],
.ingredient-row input[type="number"] {
    height: 38px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .container {
        padding: 1.25rem;
    }
    
    .tags-row-three {
        grid-template-columns: 1fr;
    }
    
    .ingredient-row {
        grid-template-columns: 1fr;
    }
    
    nav {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 10px;
    }
}



/* Default row background */
tr td {
    background: var(--surface);
}

/* Rating-based row backgrounds - more specific selector */
tr.row-rating-high td {
    background-color: rgba(16, 185, 129, 0.10) !important;
}

tr.row-rating-medium td {
    background-color: rgba(245, 158, 11, 0.10) !important;
}

tr.row-rating-low td {
    background-color: rgba(239, 68, 68, 0.10) !important;
}

tr.row-rating-none td {
    background-color: rgba(100, 116, 139, 0.06) !important;
}
