:root {
    --primary: #d4783c;
    --primary-dark: #b8632d;
    --secondary: #7a4f2e;
    --accent: #f4a460;
    --success: #6fa84e;
    --danger: #d9534f;
    --warning: #f0ad4e;
    --dark: #2c1810;
    --light: #f8f5f2;
    --gray: #6c757d;
    --border: #ddd;
    --shadow: rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: var(--light);
    background-image: linear-gradient(rgba(248,245,242,0.9), rgba(248,245,242,0.9)), url('/images/bg_recetario.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--secondary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: var(--primary-dark);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(165deg, var(--secondary) 0%, var(--dark) 100%);
    box-shadow: 2px 0 10px var(--shadow);
    overflow-y: auto;
    z-index: 1100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a {
    color: rgba(255,255,255,0.92);
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.14);
    color: white;
}

.sidebar-nav a.btn {
    display: block;
    text-align: center;
}

.sidebar-toggle {
    position: fixed;
    top: 1.25rem;
    left: 280px;
    width: 34px;
    height: 52px;
    border: none;
    border-radius: 0 10px 10px 0;
    background: linear-gradient(180deg, var(--secondary) 0%, var(--dark) 100%);
    box-shadow: 2px 2px 8px var(--shadow);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: left 0.3s ease, background 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--primary);
}

.sidebar-toggle span {
    width: 18px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

body.sidebar-open .sidebar-toggle {
    opacity: 0;
    pointer-events: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
}

.main-content {
    margin-left: 280px;
    min-height: 100vh;
    padding: 2rem 0;
    transition: margin-left 0.3s ease;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}

body.sidebar-hidden .main-content {
    margin-left: 0;
}

body.sidebar-hidden .sidebar-toggle {
    left: 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Card */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    color: white;
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 1.2rem;
}

.card-body {
    padding: 1.5rem;
}

/* Grid de recetas */
.recetas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.receta-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.receta-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px var(--shadow);
}

.receta-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--accent), var(--primary));
}

.receta-content {
    padding: 1.25rem;
}

.receta-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--secondary);
}

.receta-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--gray);
    margin-top: 0.75rem;
}

.receta-meta span::before {
    margin-right: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: var(--gray);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    transition: border 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error, .alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.table tr:hover {
    background: #f8f9fa;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success { background: var(--success); color: white; }
.badge-danger { background: var(--danger); color: white; }
.badge-warning { background: var(--warning); color: white; }
.badge-primary { background: var(--primary); color: white; }

/* Hero */
.hero {
    background-image: linear-gradient(rgba(20, 12, 8, 0.78), rgba(20, 12, 8, 0.78)), url('/images/bg_recetario.png');
    background-size: cover;
    background-position: center;
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    color: white;
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
}

/* Utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Footer */
.footer {
    background: var(--dark);
    color: rgba(255,255,255,0.8);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Dropdown para selector de comercios */
.sidebar .dropdown,
.sidebar-nav .dropdown {
    position: relative;
}

.sidebar .dropdown-toggle,
.sidebar-nav .dropdown-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255,255,255,0.9);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    width: 100%;
}

.sidebar .dropdown-toggle:hover,
.sidebar-nav .dropdown-toggle:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.sidebar .dropdown-menu,
.sidebar-nav .dropdown-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 250px;
    list-style: none;
    padding: 0.5rem 0;
    display: none;
    z-index: 1000;
}

.sidebar .dropdown.active .dropdown-menu,
.sidebar-nav .dropdown.active .dropdown-menu {
    display: block;
}

.sidebar .dropdown-menu li,
.sidebar-nav .dropdown-menu li {
    margin: 0;
}

.sidebar .dropdown-menu a,
.sidebar-nav .dropdown-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: #333;
    border-radius: 0;
    transition: background 0.2s;
}

.sidebar .dropdown-menu a:hover,
.sidebar-nav .dropdown-menu a:hover {
    background: var(--light);
    color: var(--primary);
}

.sidebar .dropdown-menu a.active,
.sidebar-nav .dropdown-menu a.active {
    background: var(--light);
    color: var(--primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .sidebar {
        width: min(84vw, 320px);
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        left: 1rem;
        top: 0.75rem;
        width: 42px;
        height: 42px;
        border-radius: 8px;
        box-shadow: 0 2px 8px var(--shadow);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem 0;
        padding-top: 4rem;
    }

    .container {
        padding: 0 1rem;
    }

    h1 { font-size: 1.9rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.35rem; }

    .card-header.d-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .recetas-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .btn {
        padding: 0.55rem 1rem;
    }
}
