/* ── Variables globales ──────────────────────────────────── */
:root {
    --brand-green: #1a5e35;
    --brand-green-light: #2d8a52;
    --brand-green-dark: #0f3d22;
    --danger: #dc3545;
    --danger-dark: #a71d2a;
    --warning: #f0ad4e;
    --success: #28a745;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #adb5bd;
    --gray-700: #495057;
    --gray-900: #212529;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 240px;
}

/* ── Reset y base ────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--gray-900);
    background: var(--gray-100);
}

/* ── Página de login ─────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-green-dark), var(--brand-green));
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    color: var(--brand-green);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-card p {
    color: var(--gray-700);
    margin-bottom: 28px;
    font-size: 13px;
}

/* ── Layout del dashboard ────────────────────────────────── */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--brand-green-dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
}

.sidebar-header p {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 13px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
    border-left-color: var(--brand-green-light);
}

.nav-item .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ── Contenido principal ─────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--white);
    padding: 16px 28px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
}

.content-area {
    padding: 28px;
    flex: 1;
}

/* ── Secciones ───────────────────────────────────────────── */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

/* ── Formularios ─────────────────────────────────────────── */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-900);
    transition: border-color 0.2s;
    background: var(--white);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--brand-green);
}

.field textarea {
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Botones ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary {
    background: var(--brand-green);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-green-light);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Tabla de items ──────────────────────────────────────── */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-card {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-card.dragging {
    opacity: 0.5;
    border: 2px dashed var(--brand-green);
}

.item-card.drag-over {
    border: 2px dashed var(--brand-green-light);
    background: rgba(45, 138, 82, 0.05);
}

.drag-handle {
    cursor: grab;
    color: var(--gray-500);
    font-size: 18px;
    padding: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--gray-200);
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-info strong {
    display: block;
    font-size: 14px;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-info span {
    font-size: 12px;
    color: var(--gray-500);
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Badge activo/inactivo ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Preview de imagen ───────────────────────────────────── */
.image-preview {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--gray-200);
    margin-top: 8px;
    display: none;
}

.image-preview.visible {
    display: block;
}

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    display: none;
}

.alert.visible {
    display: block;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #155724;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #721c24;
}

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Upload de imagen ────────────────────────────────────── */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.upload-area:hover {
    border-color: var(--brand-green);
    background: rgba(26, 94, 53, 0.03);
}

.upload-area p {
    color: var(--gray-500);
    font-size: 13px;
    margin-top: 6px;
}

/* ── Estado vacío ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.empty-state p {
    margin-top: 8px;
    font-size: 13px;
}

/* ── Logout button ───────────────────────────────────────── */
.btn-logout {
    width: 100%;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
    color: var(--white);
}